Git Product home page Git Product logo

Comments (12)

v-chojas avatar v-chojas commented on July 17, 2024

An ODBC trace will be more useful to compare the differences.

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

FWIW, the strace outputs show no evidence of pyodbc loading shared objects from different locations with v4 vs v5.

Also, this code works fine under Ubuntu 22.04 with pyodbc 5.1.0 and MariaDB Connector/ODBC v3.1.15 so pyodbc_5 does not have a problem with libmaodbc per se.

import pyodbc

print(pyodbc.version)
# 5.1.0

cnxn = pyodbc.connect(
    "Driver=MariaDB Unicode;"
    "Server=192.168.0.199;"
    "UID=scott;"
    "PWD=tiger;"
    "Database=test;"
)
print(cnxn.getinfo(pyodbc.SQL_DRIVER_NAME))
# libmaodbc.so
print(cnxn.getinfo(pyodbc.SQL_DRIVER_VER))
# 03.01.0015
crsr = cnxn.cursor()
print(crsr.execute("select version()").fetchval())
# 10.5.5-MariaDB-1:10.5.5+maria~focal

from pyodbc.

dhamonex avatar dhamonex commented on July 17, 2024

I've created some ODBC traces for both pyodbc versions:

pyodbc_5.1.0_odbctrace.log
pyodbc_4.0.39_odbctrace.log

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

Aha. So in both cases pyodbc calls SQLDriverConnectW which returns SQL_ERROR. pyodbc_4 immediately calls SQLDriverConnect which succeeds. pyodbc_5 calls SQLGetDiagRecW which returns SQL_NO_DATA. I don't know for sure if SQLGetDiagRecW returning SQL_NO_DATA translates into a 'The driver did not supply an error!' exception, but it seems plausible.

It appears that pyodbc_4 did not worry too much about SQLDriverConnectW failing and just soldiered on with SQLDriverConnect, while pyodbc_5 tries to find out why SQLDriverConnectW failed. Maybe pyodbc_5 just needs behave like pyodbc_4 in this particular case.

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

@dhamonex - Do you get the error with pyodbc_5 if you use

conn = pyodbc.connect(
    connection_string,
    ansi=True
)

from pyodbc.

dhamonex avatar dhamonex commented on July 17, 2024

I'm getting the same error as before, I've also attached the ODBC trace for ansi=True:

pyodbc_5.1.0_ansi_odbctrace.log

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

Okay, thanks. It looks like 5c1f1c0 completely removed the ansi flag, so it doesn't do anything any more. 🤷

I've tried a couple of older "ANSI" drivers (MySQL and PostgreSQL) but they seem to be okay with SQLDriverConnectW so I don't really know if this is a deficiency of that particular MariaDB driver or is something that pyodbc_5 should be able to handle. (Given the idiosyncrasies of all the ODBC drivers out there I would hope for the latter, but I'm not really qualified to say.)

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

@v-chojas - Does the ODBC spec say anything about drivers returning SQL_ERROR for SQLDriverConnectW if they simply do not "do" Unicode?

from pyodbc.

v-chojas avatar v-chojas commented on July 17, 2024

If the driver doesn't have the W functions the DM should do the narrowing conversion and then call the A function of the driver if the application calls the W function of the DM. However there has been a history of bugs around that part, especially in the DM and confusion between character and byte counts for length parameters. There may also be drivers that have both A and W functions, but one of them doesn't work. What version of unixodbc is the OP using?

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

What version of unixodbc is the OP using?

@dhamonex - You could ask your package manager or use the odbcinst -j command to check.

from pyodbc.

dhamonex avatar dhamonex commented on July 17, 2024

Tumbleweed is using unixODBC 2.3.12 the applied patches can be viewed here: https://build.opensuse.org/package/show/openSUSE%3AFactory/unixODBC

from pyodbc.

laurentderu avatar laurentderu commented on July 17, 2024

FWIW the same problem occurs on Debian Bullseye, which ships odbc-mariadb version 3.1.9 and unixodbc version 2.3.6

from pyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.