Open apiszcz opened 8 years ago
In what language is this postgres installation?
English on Windows 10 i switched to PostgreSQL no issues.
On Thu, Jul 7, 2016 at 7:19 AM, Daniele Varrazzo notifications@github.com wrote:
In what language is this postgres installation?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/psycopg/psycopg2/issues/442#issuecomment-231050826, or mute the thread https://github.com/notifications/unsubscribe/ABXVTSRMgKe2pxXExI1A9Pp7j08cl8jdks5qTOCngaJpZM4I5CRM .
The above causes an error because "create database if not exists" doesn't exist.
In [11]: cnn.set_client_encoding('win1252')
In [12]: cur.execute("create database if not exists asdf ")
---------------------------------------------------------------------------
ProgrammingError Traceback (most recent call last)
<ipython-input-12-8557d908ff45> in <module>()
----> 1 cur.execute("create database if not exists asdf ")
ProgrammingError: syntax error at or near "not"
LINE 1: create database if not exists asdf
^
I believe this message gets localized in a locale that has chars not supported in cp1252, which postgres emits anyway but python then barfs trying to decode, in a codepath that doesn't handle the exception properly. I should make myself a Japanese database to play with...
However if you say that postgres is in English for you, then my theory doesn't work here because, as you see above there is no problem receiving the exception in English.
@dvarrazzo I think it's the other way around, python is in cp1252, postgres is in utf8.
Is there an explicit encoding requirement that I need to set? Thanks
cur.execute("""CREATE DATABASE IF NOT EXISTS TEST""") *\ SystemError: decoding with 'cp1252' codec failed (SystemError: returned a result with an error set)