|
Re: Coding when open conection: msg#00041python.db.psycopg.devel
Markus Bertheau escribió: В Птн, 10/03/2006 в 11:12 +0100, Oswaldo Hernández пишет: Opps, I provoke an integrity error after connect and send client encoding and also do the error: # -*- coding: UTF8 -*- import psycopg2 as pg import sys import wx app = wx.PySimpleApp(0) wx.InitAllImageHandlers() try: # these are correct database and user, the conection do ok pgcon = pg.connect("dbname=soft-com user=postgres") except: ex = "Exception:\n%s\n(%s)" % (sys.exc_info()[1], sys.exc_info()[0]) # print don't cause error print ex wx.MessageDialog(None, ex, '', wx.ICON_ERROR | wx.OK).ShowModal() sys.exit() # message with « and » chars, shows good wx.MessageDialog(None, " « Connection OK »", '', wx.ICON_ERROR | wx.OK).ShowModal() pgcon.set_client_encoding('UTF8') try: # -> this execute cause an integrity error <- pgcon.cursor().execute("delete from pruebas.prueba1 where serie ='a' and numero = 1") except: ex = "Exception:\n%s\n(%s)" % (sys.exc_info()[1], sys.exc_info()[0]) # print don't cause error print ex # ---> when try to show this dialog the error is generated dlg = wx.MessageDialog(None, ex, '', wx.ICON_ERROR | wx.OK).ShowModal() sys.exit() the output is: Exception: update o delete en ½prueba1╗ viola la llave forßnea ½fkprueba1╗ en ½prueba1cuerpo╗ DETAIL: La llave (serie,numero)=(a,1) todavÝa es referida desde la tabla ½prueba1cuerpo╗. (psycopg2.IntegrityError) Traceback (most recent call last): File "X:\Python\scLib\perror.py", line 31, in ? dlg = wx.MessageDialog(None, ex, '', wx.ICON_ERROR | wx.OK).ShowModal() File "C:\Python24\lib\site-packages\wx-2.6-msw-unicode\wx\_windows.py", line 3030, in __init__ newobj = _windows_.new_MessageDialog(*args, **kwargs) File "C:\Python24\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode byte 0xab in position 30: unexpected code byte I'm confused, I can save and retrieve data with these chars without problems. -- ***************************************** Oswaldo Hernández oswaldo-aXkDUzFGsCcxAGwisGp4zA@xxxxxxxxxxxxxxxx ***************************************** |
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | [psycopg] #126: zohoo.com: 00041, psycopg |
|---|---|
| Next by Date: | Re: Trac spam: 00041, Peter Fein |
| Previous by Thread: | Re: Coding when open conectioni: 00041, Markus Bertheau |
| Next by Thread: | Re: Coding when open conection: 00041, Federico Di Gregorio |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |