Memory allocation failure in Windows python3
sys2065 opened this issue · 8 comments
Just to let you know, connecting to db in Windows with python3 pyodbc fails like this:
C:\>python
Python 3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
>>> import pyodbc
>>> pyodbc.connect('driver={FreeTDS};')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
pyodbc.OperationalError: ('HY001', '[HY001] [FreeTDS][SQL Server]Memory allocation failure (0) (SQLDriverConnect); [HY001] [FreeTDS][SQL Server]Memory allocation failure (0)')
Spent fair amount of time degugging this problem and finally found the cause.
You need to add ClientCharset=UTF-8 to connectionstring when connecting in Windows with python pyodbc.
Hope this helps someone else and google finds this.
In my opinion this is bug, there should at least be better errormessage to point user into right direction.
2273 downloaded from AppVeyor artifacts.
Did you really use pyodbc.connect('driver={FreeTDS};')
or did you strip other parameters? This connection string is pretty weird. Can you enable logging https://www.freetds.org/userguide/logging.html and post it? Which FreeTDS version did you use?
That example is just easiest way to reproduce the issue. It doesn't matter what parameters are, it only works if ClientCharset=UTF-8 is included.
Also I believe "memory error" should never happen.
Version already mentioned, I used vs2019_64-master.zip, direct link:
https://ci.appveyor.com/project/FreeTDS/freetds/builds/48502596/job/l1ggk563sx25g8lp/artifacts
Which language is your system/user using?
Indeed memory error is pretty misleading.
Language is fi / finnish
Can you try with build 2782 https://ci.appveyor.com/project/FreeTDS/freetds/builds/48605050 ?
Works now, thank you.
"Invalid \"%s \"character set specified"
I guess should be:
"Invalid \"%s\" character set specified"
Backported to 1.4
branch too.