Open GoogleCodeExporter opened 8 years ago
I can also confirm this.
cnx_string = 'DSN=devsrv;UID=sa;PWD=...;DATABASE=...'
cnx = pyodbc.connect(cnx_string)
args = (int_arg1, int_arg2, int_arg3, string_arg4)
results = cnx.cursor().execute("EXEC stored_proc (%s, %s, %s, '%s') %
args).fetchone()
This fails with the same error as above.
I am using the freetds-patched driver from ibiblio.org (date 20 jul 2010)
I tested with pyodbc 2.1.6 and 2.1.7 on sql server 2000 and 2008.
The os is lucid server x86_64
As a workaround, this works (tested with pyodbc 2.1.6, will test also with
pyodbc 2.1.7)
cnx = pyodbc.connect(...)
args = (int_arg1, int_arg2, int_arg3, string_arg4.encode("utf-8"))
results = cnx.cursor().execute("{CALL stored_proc(?, ?, ?, ?)}",
args).fetchone()
so.. using the odbc call format seems to work
Original comment by giotis.n...@gmail.com
on 26 Jul 2010 at 11:10
I tried the ODBC call in 2.1.7, but it reports
('HY000', 'The driver did not supply an error!')
Original comment by min...@gmail.com
on 26 Jul 2010 at 9:04
I am using this driver
http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-patched.tgz
Compiled with
./configure
make
make install
This installs the driver in /usr/local/lib, and the configuration is inside
/usr/local/etc/freetds.conf
also tested with pyodbc 2.1.7 and it works. I am using a DSN to connect to the
db.
Also I got this error (HY000) when I passed the arguments inside the {CALL...}
string. Maybe you should try passing the arguments as tuple in execute, like
above
arguments = (arg1, arg2)
cur.execute("{CALL stored_proc(?, ?)}", arguments)
What i also noticed is that i need to pass string arguments as
string.encode("utf-8")
Original comment by giotis.n...@gmail.com
on 27 Jul 2010 at 6:42
It sounds like the issue is a character encoding mismatch. pyodbc 2.x will
call the ANSI APIs if you supply an ANSI SQL statement, and it will call the
Unicode ones if you provide a Unicode SQL statement. Per the ODBC
specification, the Unicode versions will be passed as SQLWCHAR, which is
usually UCS2 encoding. I am seeing that a lot of drivers think that decoding
ANSI as UTF8 is acceptable, but it really isn't
Double check your connection's encoding.
Original comment by mkleehammer
on 21 Nov 2010 at 6:06
Original issue reported on code.google.com by
min...@gmail.com
on 20 Jul 2010 at 5:21