Reputation: 143
I'm using pyodbc to connect to Vertica. I've installed Vertica driver, unixodbc and pyodbc.
Now I have problem with executinq unicode queries.
con = pyodbc.connect('Driver={driver};Servername={server};Port={port};Database={db};UserName={user};password={password}'.format(...))
cur = con.cursor()
cur.execute('SELECT * FROM table') # It works
cur.execute(u'SELECT * FROM table') # It fails
The error is:
ProgrammingError: ('42601', '[42601] ERROR 4856: Syntax error at or near " (4856) (SQLExecDirectW)')
Upvotes: 1
Views: 1487
Reputation:
Looks like wrong encoding defined in vertica.ini
file(or wrong locale
setting in odbc.ini
)
vertica.ini
[Driver]
DriverManagerEncoding=UTF-16
...
odbc.ini
...
Locale = en_US@collation=binary
...
I bet on vertica.ini
. I have no MacOS to check, but by docs you need to define UTF-32
. Can you post your vertica.ini
abd odbc.ini
+ database locale?
daniel=> show locale;
name | setting
--------+--------------------------------------
locale | en_US@collation=binary (LEN_KBINARY)
(1 row)
For more info read here.
Upvotes: 1
Reputation: 2450
What version of pyodbc and python you are using? What OS?
try using first line in your python code as # -- coding: utf-8 --?
and update pyodbc sudo pip install --upgrade pyodbc
Upvotes: 0