1
votes

I'm trying to read the data from a Firebird database, created by Firebird version 2.5, by using the FDB module from Python. Unsuccessfully. I have a Python v3.7.3 on a Windows10 64 bits system.

I am able to connect to the database and read the names of its tables:

con_1 = fdb.connect(dsn='C:/Prova_Archi.eft', user='sysdba', password='masterkey')  
schema_1 = fdb.schema.Schema()  
schema_1.bind(con2)  
print (schema_1.tables[57].name)  ===>  TUtenti

I am also able to read, for a given table, the name of its columns and indices:

print ([i.name for i in con_1.schema.get_table(schema_1.tables[57].name).columns][0]) ===> ...  
print ([i.name for i in con_1.schema.get_table(schema_1.tables[n].name).indices][r]) ===> ...  

However, I am not able to extract the data!

When I try this:

cur_1 = con_1.cursor()  
cur_1.execute("select * from 'TUtenti'")  

I am given the following error:

===> DatabaseError: ("Error while preparing SQL statement:\n- SQLCODE: -104\n- Dynamic SQL Error\n- SQL error code = -104\n- Token unknown - line 1, column 15\n- 'TUtenti'", -104, 335544569)

Suggestions are highly welcome.

1

1 Answers

1
votes

The problem is that single quotes delimit a string literal, not an object name (e.g. a table name). To quote an object name you need to use double quotes, so use:

cur_1.execute('select * from "TUtenti"')