Hello,
Am 23.11.2010 17:12, schrieb John Fabiani:
> 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.
>>
> 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.
>
I can't get that to run. As far as I can tell from printing query
results psycopg2 returns datetime.timedelta for interval values, so I've
put "timedelta":"C" into the fldTypeDict. But that raises a TypeError:
Traceback (most recent call last):
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_misc.py", line
1342, in Notify
self.notify()
File
"/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
14716, in Notify
self.result = self.callable(*self.args, **self.kwargs)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dForm.py", line 126, in
__update
super(BaseForm, self).update()
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 1298,
in update
self.raiseEvent(dEvents.Update)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 991,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "/home/sib/src/dabo-trunk/dabo/lib/eventMixin.py", line 96, in
raiseEvent
bindingFunction(event)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 1278,
in __onUpdate
self.update()
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 1298,
in update
self.raiseEvent(dEvents.Update)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 991,
in raiseEvent
super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args,
**kwargs)
File "/home/sib/src/dabo-trunk/dabo/lib/eventMixin.py", line 96, in
raiseEvent
bindingFunction(event)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dPemMixin.py", line 1278,
in __onUpdate
self.update()
File "/home/sib/src/dabo-trunk/dabo/ui/dDataControlMixinBase.py",
line 102, in update
self.__dataUpdate()
File "/home/sib/src/dabo-trunk/dabo/ui/dDataControlMixinBase.py",
line 121, in __dataUpdate
self.Value = self.getBlankValue()
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dTextBoxMixin.py", line
744, in _setValue
_oldVal = self._oldVal = self.Value
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dTextBoxMixin.py", line
698, in _getValue
convertedVal = self.convertStringValueToDataType(strVal, dataType)
File "/home/sib/src/dabo-trunk/dabo/ui/uiwx/dTextBoxMixin.py", line
553, in convertStringValueToDataType
retVal = dataType(strVal)
TypeError: unsupported type for timedelta days component: unicode
Greetings,
Sibylle
_______________________________________________
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]