FreeTDS/pyodbc produces segmentation fault - driver for Raspbian? - raspbian

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?

Related

WebGL and GraphicsCriticalError in Selenium / C# on Raspberry Pi with Firefox

I have a Raspberry Pi 3b+. I wrote a .NET Core 5.0 program which uses Selenium to do some tasks on the browser. It all works 100% fine on my Windows PC. But it has errors when ran on the Raspberry Pi running 64 bit Ubuntu Server Focal version. I have the Gecko driver and Firefox installed. The program is able to complete its tasks, but throws many many errors about:
"Crash Annotation GraphicsCriticalError: |[0][GFX1-]: glxtest: Unable to open a connection to the X server (t=4.70096) [GFX1-]: glxtest: Unable to open a connection to the X server"
"JavaScript warning: https://js.arcgis.com/3.38/esri/dijit/BasemapGallery.js, line 22: WebGL warning: : WebglAllowWindowsNativeGl:false restricts context creation on this system."
"* Exhausted GL driver options. (FEATURE_FAILURE_WEBGL_EXHAUSTED_DRIVERS)"
"JavaScript warning: https://js.arcgis.com/3.38/init.js, line 1171: Failed to create WebGL context: WebGL creation failed:"
I tried installing xvfb but that did nothing. I am running headless and the driver confirms that I am running headless, but seems to be expecting a display regardless????
How do I solve these errors? Note, I do not care if I have to use Firefox, Chromium, or some other browser. But it seemed like Firefox was the most straightforward to install.
I figured it out. I changed operating systems to Raspberry Pi OS 64-bit Lite beta, easily installed Chrome and Chrome Driver... no problems.
I guess the problem was when running Ubuntu, the package repositories had mis-matching versions for arm64 packages and some things installed via 'snap', which is a no-go for programs that have to work together. On the Raspberry OS repository, they had matching versions and no 'snap'. At least it all works now in case anyone else sees this.

Microsoft Access SQL Database connection with Python 3.7.9 [duplicate]

When trying to make a program on Windows that connects to a database via ODBC, I got the following error:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.
I'm sure my code is right. It even worked on a different PC.
Why am I getting this error? And How do I fix it?
What causes this error?
The error message tells you, simply put, that the ODBC Driver Manager could not find the driver you specified in your connection string or DSN.
This can have 3 common causes:
The driver you tried to use is not installed on your system
The driver is installed, however, it doesn't match bitness of the code you're running
You made an error in typing the driver name
How do I check which drivers are installed on my system?
You can check the drivers which are installed on your system by going to the ODBC Data Source Administrator. To open it, press ⊞ Win + R, and type in: odbcad32.exe. Then check the tab Drivers for installed drivers. The Name column indicates the exact name you should use in your connection string or DSN.
If you're on 64-bit Windows, that only lists the 64-bit drivers installed on
your system. To see which 32-bit drivers are installed, press press ⊞ Win + R, and type in: C:\Windows\SysWOW64\odbcad32.exe, and go to the Drivers tab again.
The driver is installed, but it might be the wrong bitness, what do I do?
Then, you have two choices, either adjust the bitness your program is running in, or install a driver with a different bitness.
Some of the drivers that are installed by default on Windows only have a 32-bits variant. These can't be used with 64-bits programs.
You can usually identify which bitness a program is running under in task manager. In Windows 10, all 32-bit programs have (32-bit) appended to their name. If that isn't there, you're likely running a 64-bit program, and most modern programming languages and environments run on 64-bit by default, but allow you to switch to 32-bit. However, the specifics for different programming languages are outside the scope of this question.
How can I verify I didn't mistype the driver name?
An ODBC connection string looks like this:
DRIVER={DriverName};ParameterName1=ParameterValue1;ParameterNameN=ParameterValueN;
The driver name part needs to be delimited by curly braces if it might contain special characters, and needs to exactly match the installed driver name, as found in the ODBC Data Source Administrator, including spaces and typographical characters, but excluding capitalization.
Note that for deployed code, the driver must be present on the computer/server running the code.
I don't have the driver, or have the wrong bitness, where do I get the right one?
That depends on which driver you want to use.
A list of common drivers with download locations (all 32-bit and 64-bit at the same URL):
The Microsoft ODBC Driver 17 for SQL Server
The Microsoft Access database driver, which is part of the Microsoft Access Database Engine. Note that simultaneous installations of 32-bit and 64-bit Access ODBC drivers are not supported.
The MySQL ODBC connector by Oracle
The open-source SQLite ODBC driver by Christian Werner (non-official)
psqlODBC, the official PostgreSQL driver
If the driver you want to use isn't listed, the location is usually easily found using Google.
In design mode, a value has been set to the property of
TFDConnection.ConnectionDefName must be empty.

Database query tool for Mac OS X?

I need to test one odbc driver for mac.
What are database query utilities using ODBC for Mac OS X like DBForge, OmniDB etc?
Presuming you are testing a driver bound to iODBC, the ODBC driver manager that Apple ships with macOS, you should install the latest iODBC SDK update, which comes with iODBC Test.command and iODBC Demo.app (found in /Applications/iODBC/). You can execute any arbitrary ODBC query through these tools.
ODBC Bench, a separate install which simulates TPC-A and TPC-C on your own equipment/network. (You'll need to build your own binary to test a 64-bit driver, as the downloadable pre-built binary is 32-bit only.)
Most GUI-space apps on macOS are shipped with binding to iODBC, and are thus also candidates for your use.

ODBC Error: Driver not capable

I'm establishing an ODBC connection to our AS/400 in an app I'm developing. It simply does a DELETE and then an INSERT. Nothing crazy or complicated. Everything works great on my 64-bit Windows 7 Pro desktop (UPDATE: no longer true) but when I try to run the app on my 32-bit laptop for a presentation, I get the following error:
ERROR [S1C00] [Micro Focus][Rumba Data Access][S1023934]Driver not
capable. SQLSetConnectOption ERROR [IM006] [Microsoft][ODBC Driver
Manager] Driver's SQLSetConnectAttr failed ERROR
[01000][Microsoft][ODBC Driver Manager] The driver doesn't support the
version of ODBC behavior that tha pplication requested (see
SQLSetEnvAttr). ERROR [08004][Micro Focus][RUMBA Data
Access][S1023934]Data source rejected establishment of connection.
APPC Primary RC = Allocation_Error; Secondary RC =
Allocation_Failure_No_Retry.
I'm not sure what's going on. I may have messed something up when setting up the DSN on the 32-bit laptop but it looks exactly the same as what I set up on the 64-bit desktop... Is there something different between the 32-bit and 64-bit versions or is there something else going on?
Thanks!
EDIT: I just tried it on another 64-bit desktop and I got the same error. There must be something wrong with how I'm setting up the DSN since I set it up on my machine months ago and could be forgetting something.
EDIT2: I ran Windows Update on the desktop where everything worked on and now it doesn't work there either. Is it possible a buggy Windows Update could be causing my issues?
EDIT3: I was asked in the comments to enable tracing and see what happens. Skimming through it, here are a few notable messages:
EXIT SQLDriverConnectW with return code -1 (SQL_ERROR)
and:
EXIT SQLGetDiagRecW with return code 100 (SQL_NO_DATA_FOUND)
Everything else looks like it exits with a status of 0 (SQL_SUCCESS)
The issue was resolved by installing this Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update.
According to Microsoft,
A security issue has been identified leading to a vulnerability in MFC applications that are built with Visual Studio 2005 and ship the Microsoft Visual C++ 2005 Service Pack 1 Redistributable Package.
Why installing a security patch (rather than a bug fix patch) solved this is beyond me...
Using ODBC Administrator, turn on tracing. Try your application and look at the log file for SQL_ATTR_ODBC_VERSION. You should see something like this:
odbct32w fc0-1ad0 ENTER SQLSetEnvAttr
SQLHENV 0x007A1DE0
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 3 <SQL_OV_ODBC3>
SQLINTEGER 0
odbct32w fc0-1ad0 EXIT SQLSetEnvAttr with return code 0 (SQL_SUCCESS)
SQLHENV 0x007A1DE0
SQLINTEGER 200 <SQL_ATTR_ODBC_VERSION>
SQLPOINTER 3 <SQL_OV_ODBC3>
SQLINTEGER 0
The difference will be that yours is returning SQL_ERROR instead of success. Check what the third parameter is (in my case SQL_OV_ODBC3). Most likely whatever version your application is setting is newer that what your ODBC driver supports. You'll need to refrain from using newer ODBC features or upgrade your driver to something one that supports a higher level of ODBC.

(Libre Office / Base Database) always tries to connect ODBC using iODBC, not unixODBC on Mac OSX 10.10

I am using Libre Office Version: 4.3.4.1 on my Mac OSX 10.10 Yosemite.
In Base Database, I would like to connect MS-SQL server using unixODBC DSN.
But it seems the Libre Office tries to connect via iODBC, not unixODBC.
(I never installed iODBC on my Mac.)
Here is what I tried.
Following instructions, I already setup unixODBC, FreeTDS using Homebrew and all the tsql/isql connection tests were fine.
After installing, I launched "Database Wizard" from Base database.
And choose 'ODBC' from "Connect to an existing database",
I entered s01, my unixODBC DSN name, to "Name of the ODBC data source on your system" field. (When I clicked 'Browse' no registered data source were shown.)
And I typed my unixODBC username and checked Password required.
When I clicked 'Test Connection' button and input the password, an error occurred as below.
[iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded.
SQL Status: IM002
[iODBC][Driver Manager]Data source name not found and no default driver specified. Driver could not be loaded
Does anyone have an idea to solve this problem?
I would recommend you stick with iODBC, the ODBC driver manager Apple has shipped as part of OS X since Jaguar (10.2). The version Apple bundles into Yosemite (10.10) remains a bit behind, at 3.52.6, so I would also recommend you update to 3.52.10.
iODBC and UnixODBC are built to be API equivalent, so you should just need to ensure that your drivers and DSNs are properly configured in the iODBC locations, optimally via iODBC Administrator.app (/Applications/iODBC/). System DSNs are recommended for most purposes.
/Library/ODBC/odbc.ini # System DSNs
/Library/ODBC/odbcinst.ini # System drivers
~/Library/ODBC/odbc.ini # User DSNs
~/Library/ODBC/odbcinst.ini # User drivers