Tag History to CSV and Back how do i fix ignition crash?

Insert multiple rows at once. But, as @pturmel said, it may only support a few thousand question marks. I modified your script, shown below. Start with 500 rows at a time, then raise or lower depending on how it runs.

def runAction(self, event):
	import csv

    def prepInsertQmarks(numOfGroups, groupSize):
	''' 
	    Generate a string of grouped question marks for prepUpdate inserts
	    example: Generate three groups of four question marks:
	    prepInsertQmarks(3, 4) returns (?,?,?,?),(?,?,?,?),(?,?,?,?)
	'''
		group = '(' + ','.join(['?'] * groupSize) + ')'
		return ','.join([group] * numOfGroups)
	
	# get file path of upload and then convert csv data to dataset
	csvPath = "C:/test historyFri Jun 16 09 02 22 CEST 2023/sqlt_data_1_20230611.csv"
	
	csvFile = open(csvPath, 'r')
	
		
	csvRead = csv.reader(csvFile)
	csvDataset = []
	count = 0
	query = """use mijn_database INSERT INTO sqlt_data_1_2023_06 (tagid ,intvalue, floatvalue, stringvalue,datevalue,dataintegrity,t_stamp) 
			   VALUES {}"""

	for row in csvRead:
		print "test"
        # using extend instead of append adds values as a flat list to use in runPrepUpdate() later
		csvDataset.extend(row)
		count += 1
		# Based on @pturmel's information, check for 500 rows instead of 1000.
		# Reduce the count threshold value if an error occurs
		if count >= 500:
			qmarks = prepInsertQmarks(count, len(row))
			# insert orders into sql table
			system.db.runPrepUpdate(query.format(qmarks), csvDataset)
			csvDataset = []
			count = 0
	if count>0:
		qmarks = prepInsertQmarks(count, len(row))
		# insert orders into sql table
		system.db.runPrepUpdate(query.format(qmarks), csvDataset)
2 Likes