Sam Gendler <sgendler@teknolojix.com> wrote:
Is there a way to get zope to automatically keep fields returned from a SQL query as the correct type. Currently. my int fields are converted to string, which I then wind up having to convert back to int for comparisons, etc. I thought I saw some mention of a type dictionary in the db connection string, but I couldn't find any examples. I could have been mistaken, too. Someone please illuminate me. I am using MySQL by the way.
in fact, this is really something the DA (database adapter) should do. my zpostgresqlda-0.0.3 properly converts sql-int-fields to zope-integers. what mysql-da are you using? MySQLdb-0.1.0 has worked for me... thilo -- mezger@innominate.de innominate AG networking people fon: +49.30.308806-11 fax: -77 web: http://innominate.de pgp: /pgp/tm
In MySQL, numbers will end up as strings if they're bigints. Change them to int - that's usually plenty big enough - and the underlying python MySQL adaptor will stop getting upset. Test for this, in python with MySQL:
import MySQL x = MySQL.connect('host','username','password') x.selectdb('database') x.listfields('table')
Check the third field of each element in the list you get back - that shows what the datatype is, if it's 'unhandled', as bigint's appear, then it'll come back as a string. KevinL
Sam Gendler wrote
what mysql-da are you using? MySQLdb-0.1.0 has worked for me...
That is what I am using.
--sam
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope No cross posts or HTML encoding! (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
--------------- qnevhf@obsu.arg.nh --------------- Kevin Littlejohn, Technical Architect, Connect.com.au Don't let the Govt censor our access to the 'net - http://www.efa.org.au/Campaigns/stop.html
participants (3)
-
Kevin Littlejohn -
Sam Gendler -
Thilo Mezger