mkleehammer/pyodbc

windows use psqlodbc-12.2 insert string error

rorsarach opened this issue · 4 comments

Please first make sure you have looked at:

Environment

To diagnose, we usually need to know the following, including version numbers. On Windows, be
sure to specify 32-bit Python or 64-bit:

  • Python: 3.7-64b
  • pyodbc: 5.0.0b3
  • OS: windows
  • DB: pgsql-12.2
  • driver: psqlodbc-12.2

Issue

windows uses the odbc driver for pg, and use fast_executemany, inserting a string will cause an error, like this:
`
insert_list = [[1, '1'], [2, '2']]
cur.fast_executemany = True
cur.executemany('insert into test values(?, ?) ', insert_list)

create table test (id int, val char(10))

`

The program crashes on windows but works fine on linux.

Do you still get the error on Windows if you use fast_executemany = False ?

Do you still get the error on Windows if you use fast_executemany = False ?

No, if not use fast_executemany, it work ok.

fast_executemany is off by default because a lot of drivers behave unpredictably with it on. It seems support for array inserts is not widely implemented in ODBC drivers so that may be what you're experiencing.

https://github.com/mkleehammer/pyodbc/wiki/Features-beyond-the-DB-API#fast_executemany