[DB-SIG] PDO and number field

Jon Franz_antispam jfranzXREMOVEX at neurokode.com
Fri Oct 24 16:43:25 EDT 2003


It appears you are casting the result to a string - so the L is coming 
from the fact that the data type is a long.  This may be a result of the 
precision used in the MySQL column (MEDIUMINT, BIGINT, etc), 
or it could be that the underlying mysqldb module is returning a long 
for some other reason.

Anyway - you need the int representation of the string, thus you
probably need something like:

print "The value is " + str(MyResultSet['myColumn'].value)


to work around the issue.  This all happens because the repr() 
version of a long includes the L at the end, but the str() version does 
not.

Have fun, and send any feedback you have on PDO 
to pythondbo-users at lists.sourceforge.net - we're working on a 
new version and want to know what users would like to see.

~Jon Franz
NeuroKode Labs, LLC


-----Original Message-----
From: db-sig-bounces at python.org [mailto:db-sig-bounces at python.org]On
Behalf Of Derek Croxton
Sent: Friday, October 24, 2003 1:17 PM
To: db-sig at python.org
Subject: [DB-SIG] PDO and number field


I'm getting a strange result when accessing a numeric (identity) field 
in MySQL with PDO:  instead of returning 1 (or 2 or 3, etc.), it returns 
1L (or 2L or 3L, etc.).  I have no idea where this behaviour is coming 
from, nor what to do about it.  Has anyone else seen this?

(Using PDO 1.0.2 and Python 2.3.)

Sincerely,
Derek Croxton
croxton3 at yahoo.com



_______________________________________________
DB-SIG maillist  -  DB-SIG at python.org
http://mail.python.org/mailman/listinfo/db-sig




More information about the DB-SIG mailing list