Closed GoogleCodeExporter closed 9 years ago
What is returned depends on your driver. The library examines the results of
the query. For string types, there are only 2 ODBC types: SQLCHAR and
SQLWCHAR. SQLCHAR results are ANSI and are returned as 'str'. SQLWCHAR
results are UCS2 Unicode and are returned as 'unicode'.
The unicode_results flag is to force the conversion of ANSI to Unicode, but it
is not really possible to convert the other way -- not all Unicode strings can
be represented as ANSI ones.
I am going to close this since I believe it is working as designed. To be
sure, you can create an ODBC trace and see what data type is being returned to
pyodbc. If it is SQLCHAR, then there is a bug and you should reopen this.
Original comment by mkleehammer
on 27 Oct 2011 at 6:48
Actually I have noticed in connection.cpp, Connect() - the connection is being
established according to the fAsni flag. So if this flag is false, pyODBC is
trying to establish a connection using SQLDriverConnectW first - which returns
<unicode> results (instead of <str>).
If the fAnsi flag is true, OR if the SQLDriverConnectW fails, the connection is
being established using SQLDriverConnect - which returns <str> results.
The fAnsi flag can be enabled by issuing: pyodbc.connect(connection_string,
ansi=1).
The problem is that I have also switched from psqlODBC 08.04 to 09.00. In 08.04
SQLDriverConnectW always failed, so pyODBC was automatically switching to
SQLDriverConnect.
Regarding the trace - I wasn't able to produce it. Can you please assist me on
this?
Original comment by sapoj...@gmail.com
on 27 Oct 2011 at 9:28
Original issue reported on code.google.com by
sapoj...@gmail.com
on 16 Oct 2011 at 5:13