0

I wrote a small Python script to use executemany(sql, *params), with fast_executemany=True. Running it produces a 'segmentation fault' error.

The fast_executemany = True uses an ODBC feature called "parameter arrays" and that feature is not supported by all ODBC drivers. Apparently, FreeTDS ODBC is one of those drivers that does not support it.

The Internet suggests Microsoft's ODBC Driver for SQL Server, but I cannot install this on my Raspberry Pi running Raspbian (32 bit).

Are there any other drivers that could help me out?

  • There are third-party (not free) drivers but I assume you already know that. You could continue to work with FreeTDS if you created table value constructors (TVCs) to insert multiple rows with a single INSERT statement. – Gord Thompson May 23 '20 at 20:16
  • @GordThompson I use exactly one INSERT INTO statement, using crsr.executemany(query, params), where params is a list of tuples. Last run uploaded 5000 rows in 84 seconds, which is too slow. With crsr.fast_executemany = False. Do you mean 'drop the tuples'? Which paid drivers can you recommend? – Nils Deschrijver May 23 '20 at 21:10
  • I mean construct a statement that inserts more than one row, e.g., `INSERT INTO gord_t (col1, col2) VALUES (?, ?), (?, ?), (?, ?), ...` and then pass multiple rows' worth of values for each invocation (`.execute` or even [not fast] `.executemany`). Sort of like "inline batching" of rows. SQL Server TVCs can insert up to 1000 rows at a time. As for paid drivers, I've never needed to use one. – Gord Thompson May 24 '20 at 12:42
  • Come to think of it, using [turbodbc](https://pypi.org/project/turbodbc/) instead of pyodbc (with FreeTDS ODBC) may take care of that for you. – Gord Thompson May 24 '20 at 14:02
  • I've never tried it, but would one of the Debian MSODBC releases work for Raspberry Pi, since it is Debian based? https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#debian17 – FlipperPA May 25 '20 at 01:55

0 Answers0