On Tuesday, November 23, 2010 07:51:38 am Sibylle Koczian wrote:
> Am 22.11.2010 16:09, schrieb John Fabiani:
> > What is the data type returned from psycopg?  If you review what is being
> > done in dbPostgres.py (that is where the python data types are being
> > set) it might be possible to add the data type.
> 
> Psycopg returns datetime.timedelta, and this isn't always right
> (interval values of one or more months or years). I'm using the version
> that comes with Ubuntu, so it's probably compiled without mx support,
> even if mx is installed.
> 
> For my applications I would be quite happy to treat interval values as
> strings throughout the program and to have the database do all
> calculations with them. But I don't know how to get my bizobj to do that.
> 
> Greetings
> Sibylle

Here is how - make a small addition to the dbPostgres.py.  At approximately 
line 173 add the return value to the dict.

fldTypeDict= {"int4":"I", "int8":"I", "int2":"I","varchar": "C",  "char": 
"C",'bpchar': 'C', "bool":"B", "text": "M", "numeric":"N", "double":"F", 
"real":"F","float4":"F", "float8":"F", "datetime":"T", "timestamp":"T", 
"date": "D","bytea": "L", "point":"C", "box":"C", "circle":"C", "lseg":"C", 
"polygon":"C", "path":"C","oid":"I"}

You will notice I have NOT included the data type of interval (BTW I'm not 
sure what psycopg returns as a data type - you'll have to determine that 
info).  For example if psycopg returns the string 'interval' you would add
"interval":'C' 
to end of the dict.

Then you can use the data type all you want.  Of course it will be up to you 
to handle the use of the added data type.  But Dabo will be able to retrieve 
and save the value because Dabo will assume it's a string.  None of the 
special postgres capabilities for the data type will be available.

Johnf
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to