Segmentation Fault via ODBC between Docker containers

I am currently developing a solution that involves working between Docker containers. On one hand, I have a virtuoso instance by pulling the latest image ( openlink/virtuoso-opensource-7:latest) and both ports (8890 and 1111) exposed and published for that container (container named: virtuoso_container). On the other hand, I have an application that needs to connect to Virtuoso so that it can persist some data as relational tables through Python. I have installed pyodbc as well as unixodbc (2.3.6) & libvirtodbc0. I’ve set the odbc.ini file as follows:

[VOS]
Driver=Virtuoso
Address=virtuoso_container:1111
UID=dba
PWD=dba
Database=mytable

and the odbcinst.ini as so:

[Virtuoso]
Driver=/usr/lib/x86_64-linux-gnu/odbc/virtodbc_r.so

Both files are located under the /etc/ directory. After connecting both containers on the same network, I am able to connect to virtuoso through the other container’s terminal via isql command as so:

# isql VOS dba dba
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL>

However, when I try to connect the same way to Virtuoso with Python with the following command

pyodbc.connect('DSN=VOS;UID=dba;PWD=dba')

I get a Segmentation Fault, but without any further description or information to better understand the problem.

Why is this happening ? How can this be solved ?

Thank you in advance.

Where is the segmentation fault occurring in the pyodbc application or the Virtuoso docker container instance ?

I presume the unixODBC isql connection successfully made with the VOS DSN is on the same container the pyodbc connection failing is run from and the Virtuoso docker container is still online having verified the isql connection ?

What is the libvirtodbc0 component you installed and where did you obtain it from as I don’t know of such a component ? I assume that is where the /usr/lib/x86_64-linux-gnu/odbc/virtodbc_r.so comes from ?

The Segmentation fault is happening in the pyodbc application (my custom docker application).
Exactly, both connections are being made from my custom docker application trying to connect to the other Virtuoso Docker container.
The libvirtodbc0 (is being installed as part of the Dockerfile build in my custom docker app so that it installs the drivers virtodbc_r.so, virtodbcu_r.so, virtodbc.so and virtodbcu.so in the path /usr/lib/x86_64-linux-gnu/odbc/. As I need them to set them to add the path for the Virtuoso driver in the odbcinst.ini file.

P.S.: I also tried connecting with sqlalchemy’s create_engine method with the following URL virtuoso+pyodbc://dba:dba@VOS but it also launches the Segmentation fault exception

libvirtodbc0 is an old Virtuoso Debian package from 2018 , with old 7.2.5 components which is probably the last time the Debian team built Virtuoso components. Whereas the latest components are 7.2.12 and have a number of unixODBC and other wide character fixes you would benefit from.

We have a Generic Linux Virtuoso open source 7.2.12 installer containing prebuilt generic binaries that will run on any glibc 2.5 or higher Linux distribution and is what you need to download and use the virtodbc_r.so ODBC driver file it contains. Or probably the virtodbcu_r.so for unicode support. although that would require the setting of the WideAsUTF16 = Yes ODBC DSN attribute for it to work correctly with unixODBC.

1 Like

Appreciate your answer ! That was indeed what I needed. Switching from the libvirtodbc0 to the Generic Linux Virtuoso open source 7.2.12 solved my issue and the connection can be stablished without any problem. Thank you very much for your help !

Great, good to hear the connection is now working …