I am trying to use kinterbasdb and Python 2.7 to write data to a Firebird database on a server, and print the key value of the added data. It works perfectly when I write to a local copy of the database.
insert = """INSERT INTO myTable (myID,DT_TIMESTAMP)
VALUES (?,?)
RETURNING myTable_KEY"""
data = ("idTest", datetime.now())
conAdd = kinterbasdb.connect(dsn=nm, user=dbUser, password=dbPass)
cur = conAdd.cursor()
cur.execute(insert, data)
return_key = cur.fetchone()[0]
conAdd.commit()
cur.close()
But the word returning
causes a problem when accessing the database on the network:
ProgrammingError: (-104, 'isc_dsql_prepare: \n Dynamic SQL Error\n SQL error code = -104\n Token unknown - line 3, column 13\n RETURNING'
Looking at the version of Firebird, the local version is 2.0 and the server version is 1.5. I don't understand this, as I've just copied the server version to my local drive for testing. I'm using kinterbasdb, which I thought would be the interface to the database whether it was local or on the server. It turns out that v2.0 has the 'returning' word but v1.5 doesn't. And I need my Python code to work on the server version.
I have two questions: Why are the versions different? And how can I get the key value returned in v1.5 (multiple simultaneous users will be entering data)?