Hello everybody,
I have a script using Python that uses the INSERT statement to input data into a table, using something like the test statement below
cursor.execute(' INSERT INTO tbl_test (fld_PK, fld_value1, fld_value2) VALUES (?,?,?)'),(ID, name, address))
This wont work if I have a duplicate primary key (fld_PK) and the program crashes.
I did a test and incremented the primary key value by 0.1 and set the integer type to double and ran the program again and it inserted the new record directly after the original one ( I'm guessing that you already knew this! I was just expecting to stick at the end of the table).
So if a duplicate key exists is there I can INSERT at this position but REPLACE? as I will only need to replace a few fields. Ive tried INSERT IGNORE but apparently that's not supported anymore - the INSERT IGNORE statement would have been really useful as it would have provided a warning as well. I don't want to change the PK to accept duplicates in MS Access either - has anybody suggestions as to how I might get this to work please? - there's probably a better way to do this
any help appreciated
I have a script using Python that uses the INSERT statement to input data into a table, using something like the test statement below
cursor.execute(' INSERT INTO tbl_test (fld_PK, fld_value1, fld_value2) VALUES (?,?,?)'),(ID, name, address))
This wont work if I have a duplicate primary key (fld_PK) and the program crashes.
I did a test and incremented the primary key value by 0.1 and set the integer type to double and ran the program again and it inserted the new record directly after the original one ( I'm guessing that you already knew this! I was just expecting to stick at the end of the table).
So if a duplicate key exists is there I can INSERT at this position but REPLACE? as I will only need to replace a few fields. Ive tried INSERT IGNORE but apparently that's not supported anymore - the INSERT IGNORE statement would have been really useful as it would have provided a warning as well. I don't want to change the PK to accept duplicates in MS Access either - has anybody suggestions as to how I might get this to work please? - there's probably a better way to do this
any help appreciated