problem with psqlite2 return types

Danny shevitz at
Thu Jul 19 00:47:26 CEST 2007


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,
		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[table]
		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?


More information about the Python-list mailing list