problem with psqlite2 return types

D

Danny

Howdy,

I'm having troubles with psqlite2 and the return types from a query. The problem
is that my data which is numeric, is being returned as a string. I'm aware of the
detect_types=sqlite.PARSE_DECLTYPES argument to the connect function.

Here's my connection code:
self.connection = sqlite.connect(self.dbFile,
detect_types=sqlite.PARSE_DECLTYPES)#
self.connection.text_factory=str
self.cursor = self.connection.cursor()

Here's my sql (I'm returning risk1, which is numeric):
create table risk(
quantity varchar(8),
color varchar(8),
risk1 real,
risk2 real,
primary key (quantity, color)
);

( I have also tried [REAL, float, FLOAT], none work for me)

Here's my query (this will probably be not much use out of context...):
primaryKeys = self.primaryKeyFields

primaryKeyList= ' and '.join(['%s = ?'% pKey for pKey in primaryKeys])
query = 'select %s from %s where %s' % (field, table, primaryKeyList)
paramList = [state[primaryKey] for primaryKey in primaryKeys]
self.cursor.execute(query, paramList)

Any ideas?

TIA,
Danny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top