pgdb doesn't work with db.py. #23

Closed
cninucci opened this Issue Aug 16, 2010 · 1 comment

Projects

None yet

2 participants

@cninucci

I only have pgdb installed on my system and I can't use Postgrès with web.db.
I get the following exceptions:

File "/usr/lib64/python2.6/site-packages/web/db.py", line 918, in _connect
conn.set_client_encoding('UTF8')
AttributeError: 'pgdbCnx' object has no attribute 'set_client_encoding'

Indeed, pgdb module doesn't provide this method or any equivalent.

Here's a patch for the db.py file that works at home, I think it will preserve the behavior for psycopg* users. I did'nt figure out how to know which module in the was used in the _connect contexte, so I exploited the AttributeError exception to call the correct method.

918c918,921
<         conn.set_client_encoding('UTF8')

---
>         try:
>             conn.set_client_encoding('UTF8')
>         except (AttributeError):
>             conn.cursor().execute("set client_encoding to 'UTF-8'")

There's the same issue with _connect_with_pooling, but I didn't meet her ;)
Have a nice day :)

@anandology
Contributor

Fixed error in creating PostgresDB with pgdb driver. Closed by 35674c8 (tx cninucci)

@s7v7nislands s7v7nislands pushed a commit to s7v7nislands/webpy that referenced this issue May 4, 2011
@anandology anandology Fixed error in creating PostgresDB with pgdb driver. Closes #23 (tx c…
…ninucci)
35674c8
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment