Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows use psqlodbc-12.2 insert string error #1306

Closed
rorsarach opened this issue Nov 22, 2023 · 4 comments
Closed

windows use psqlodbc-12.2 insert string error #1306

rorsarach opened this issue Nov 22, 2023 · 4 comments

Comments

@rorsarach
Copy link

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.

@gordthompson
Copy link
Collaborator

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

@rorsarach
Copy link
Author

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

No, if not use fast_executemany, it work ok.

@v-chojas
Copy link
Contributor

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

@gordthompson
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants