Open ScapeKP opened 3 years ago
FWIW, I just tried this …
import pyodbc
cnxn = pyodbc.connect("DSN=paradox", autocommit=True)
crsr = cnxn.cursor()
next_id = crsr.execute("SELECT MAX(ID) FROM Test").fetchval() + 1
print(f"inserting ID={next_id}")
sql = "INSERT INTO Test (ID, NAME, FULLNAME) VALUES (?, ?, ?)"
data = (next_id, f"name{next_id}", f"fullname{next_id}")
crsr.execute(sql, data)
print(crsr.execute("SELECT * FROM Test").fetchall())
… and although the SELECT was successful ("inserting ID=2") the INSERT failed with …
Traceback (most recent call last):
File "C:/Users/Gord/Desktop/foo.py", line 9, in <module>
crsr.execute(sql, data)
pyodbc.Error: ('HY000', '[HY000] [Microsoft][ODBC Paradox Driver] Operation must use an updateable query. (-3035) (SQLExecDirectW)')
… which doesn't look promising.
(However, I freely admit that I know nothing about the Paradox ODBC driver for Windows. The last time I used Paradox was version 3.5 for DOS, about 30 years ago.)
I'm trying to insert something into paradox .db file, but I get this error:
TypeError: visit_insert() takes 2 positional arguments but 3 were given
I don't understand, what I'm doing wrong. I read docs and surf a lot, tried different code, but it doesn't work anyway....
My code:
Select statement works fine (and even update). And a little about my Test table. This code:
gives this results
How to make insert work?
Test.db in attach Test.zip