I am trying to insert data into a 4D database using pyodbc driver. I am able to connect and get data that i prevoiusly inserted using the same format. Here is the code:
#Connection string
class Database():
def __init__(self):
self.conn = pyodbc.connect('DRIVER={4d v20 ODBC Driver 64-bit};SERVER=127.0.0.1;UID=Designer;PWD=123456') # This works
self.curs = self.conn.cursor()
#Function
feed_analysis_data = (data.dateArrivedLab, user_id, data.labAnalysisID, data.feedName, data.harvestDate)
sql_query = "INSERT INTO feed_analysis (date, user_id, lab_analysis_id, feed_name, date_harvested) VALUES (?, ?, ?, ?, ?)"
try:
self.curs.execute(sql_query, feed_analysis_data)
except Exception as e:
print("Error executing SQL query:", e)
I have checked the inserted data, all the parameters are present there.
I have tried using %s, ?, '?', :1... as parameter markers but i still get the same error message: Error executing SQL query: ('The SQL contains 0 parameter markers, but 5 parameters were supplied', 'HY000')
I have searched online and here at SO, but none of the things i found works for what i am encountering. Any insight would be appreciated.