MariaDB Python OperationalError: This feature is not implemented or disabled - mariadb

I've compiled and installed Python 3.10.9 (from .tar) and mariadb-c-connector (from official Github repo) on my Debian 11 (bullseye) machine.
I also installed: ufw, fail2ban, mariadb-server, mariadb-client.
Now if i install mariadb in my Python pipenv and run i got the error: mariadb.OperationalError: This feature is not implemented or disabled.
On my Manjaro it works fine. This is how i create a connection to the database.
def connect(self):
if self.conn:
return
# Connect to MariaDB Platform
try:
self.conn = mariadb.connect(
user=self.user,
password=self.password,
host=self.host,
port=self.port,
database=self.database,
reconnect=True,
)
except mariadb.Error as e:
log.exception(f"Error connecting to MariaDB Platform: {e}")
self.conn = None
return
What i do wrong or what is missing?
Thank you in advance.
Edit:
Output of mariadb_config --cc_version --libs
3.3.4
-L/usr/lib/mariadb/ -lmariadb
Output of ldd /home/USER/.local/share/virtualenvs/PROJEKT/lib/python3.10/site-packages/mariadb/_mariadb.cpython-310-x86_64-linux-gnu.so
linux-vdso.so.1 (0x00007fffa2eec000)
libmariadb.so.3 => /lib/x86_64-linux-gnu/libmariadb.so.3 (0x00007f6911918000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6911743000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f691173d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f691171b000)
libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f6911688000)
libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f6911394000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f6911375000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6911988000)

This is the check in source code:
#if MARIADB_PACKAGE_VERSION_ID > 30301
if (mysql_optionsv(self->mysql, MARIADB_OPT_STATUS_CALLBACK, MrdbConnection_process_status_info, self))
goto end;
#endif
It fails, since mysql_optionsv doesn't support the option MARIADB_OPT_STATUS_CALLBACK and returns error CR_NOT_IMPLEMENTED.
Update (after more details were added to the original question):
So it looks like you built (installed) the mariadb module with the correct required Connector/C version (> 3.3.1) , however there is an older Connector/C version in your default library path libmariadb.so.3 => /lib/x86_64-linux-gnu/libmariadb.so.3 (which was likely installed with package libmariadb-dev)

I had the same problem in a docker environment with python 3.11-slim and mariadb 10.11-rc. I also installed mariadb==1.1.5.post3.
I updated the MariaDB Connector/C using the following instruction.
Here's what I did in my Dockerfile
RUN apt-get update && apt-get install -y gcc curl wget
RUN wget https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
RUN chmod +x mariadb_repo_setup
RUN ./mariadb_repo_setup \ --mariadb-server-version="mariadb-10.6"
RUN apt install -y libmariadb3 libmariadb-dev
These commands helped me update the library to the new version.
In my connection code, I also replaced host with the name of the service from the docker-compose.yml file. In my case it will be db
from os import getenv
import mariadb
con = mariadb.connect(
host='db',
user=getenv('DB_USER', default=''),
password=getenv('DB_PASS', default=''),
database=getenv('DB_NAME', default=''),
)
cur = con.cursor()
I hope these commands help resolve the issue in your environment

Related

RODBC error connecting to Netezza: Can't open lib libnzodbc.so file not found

I'm unable to connect to a Netezza appliance within either R command line or Rstudio. However, I am able to connect to the appliance using isql and nzodbcsql command line tools.
Here's my config so far in Redhat Linux:
1. unixODBC manager installed
2. User environment variables:
LD_LIBRARY_PATH=/usr/local/nz/lib64, where the Netezza library exists. Permissions on the directories are 755
NZ_ODBC_INI_PATH=/common/odbc, where the ODBC config files are located. Permissions are also 755 at this location.
3. Ran "odbcinst -j" to check configuration of ODBC files:
unixODBC 2.3.4
DRIVERS............: /common/odbc/odbcinst.ini
SYSTEM DATA SOURCES: /common/odbc/odbc.ini
FILE DATA SOURCES..: /common/odbc/ODBCDataSources
USER DATA SOURCES..: /common/odbc/odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
Able to query Netezza using isql and nzodbcsql (select * from _v_dual will return 1 record). Let's pretend the ODBC DNS name is "testdsn"
Attempting to use RODBC in an R session:
library(RODBC)
z = odbcConnect("testdsn")
Warning messages:
1: In RODBC::odbcDriverConnect("DSN=testdsn") :
[RODBC] ERROR: state 01000, code 0, message [unixODBC][Driver Manager]Can't open lib '/usr/local/nz/lib64/libnzodbc.so' : file not found
2: In RODBC::odbcDriverConnect("DSN=testdsn") :
ODBC connection failed
This error usually indicates that the LD_LIBRARY_PATH is not set correctly. I know while I have it set on the command line, it's not set for R, so I set it in Renviron.site config file.
Sys.getenv("LD_LIBRARY_PATH")
[1] "/lib64:/usr/include:/usr/lib64:/usr/local/nz/lib64"
I have also run a ldd on the libnzodbc.so file, and am not seeing any linking problems:
system("ldd /usr/local/nz/lib64/libnzodbc.so")
linux-vdso.so.1 => (0x00007fff1fdce000)
libc.so.6 => /lib64/libc.so.6 (0x00007f26ede93000)
libm.so.6 => /lib64/libm.so.6 (0x00007f26edb91000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f26ed975000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f26ed771000)
libkrb5.so.3 => /usr/local/nz/lib64/libkrb5.so.3 (0x00007f26ee58a000)
libkrb5support.so.0 => /usr/local/nz/lib64/libkrb5support.so.0 (0x00007f26ed664000)
libcom_err.so.3 => /usr/local/nz/lib64/libcom_err.so.3 (0x00007f26ed561000)
libk5crypto.so.3 => /usr/local/nz/lib64/libk5crypto.so.3 (0x00007f26ed41e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f26ee54c000)
libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f26ed205000)
I'm able to query via the unixODBC and Netezza command line tools, but can't query via R or Rstudio. As far as I can tell, I have the R environment variables set up correctly to find the library path, but it still can't find the file. Does anyone know if I'm missing anything else?
R version: 3.4.4
Netezza driver version: 3.51
Rehat version: 7.6
I figured out how to get it working. For some reason R seems to be ignoring the entries in LD_LIBRARY_PATH. Instead, I added the library location using ldconfig. Once it was added there and loaded (verified by running ldconfig -p), I was able to query in R.

Can't open Llvm in ocaml

I'm trying to use llvm binding in ocaml, in my file test.ml, I have one line of code:
open Llvm
When I run the command
ocamlbuild -use-ocamlfind test.byte -package llvm
I get this result:
+ ocamlfind ocamldep -package llvm -modules test.ml > test.ml.depends
ocamlfind: Package `llvm' not found
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
What did I do wrong in this? Thanks.
BTW, the _tag file contains:
"src": traverse
<src/{lexer,parser}.ml>: use_camlp4, pp(camlp4of)
<*.{byte,native}>: g++, use_llvm, use_llvm_analysis
myocamlbuild.ml contains:
open Ocamlbuild_plugin;;
ocaml_lib ~extern:true "llvm";;
ocaml_lib ~extern:true "llvm_analysis";;
flag ["link"; "ocaml"; "g++"] (S[A"-cc"; A"g++"]);;
I don't know why the instructions that you're using are so complex. You don't have to do anything like this to use llvm bindings in OCaml, provided you have installed them via opam.
Here is the recipe:
Install llvm bindings via opam.
it could be as simple as
opam install llvm
However, opam may try to install the latest version that is not available on your system, so pick a particular version, that you have and do the following (suppose you have llvm-3.8):
opam install conf-llvm.3.8
opam install llvm --criteria=-changed
(The -criteria flag will prevent opam from upgrading conf-llvm to the newest version)
Once it succeeds, you can easily compile your programs without any additional scaffolding.
Create and build your project
create a fresh new folder, e.g.,
mkdir llvm-project
cd llvm-project
create a sample application (borrowed from some tutorial, that I've found online):
cat >test.ml<<EOF
open Llvm
let _ =
let llctx = Llvm.global_context () in
let llmem = Llvm.MemoryBuffer.of_file Sys.argv.(1) in
let llm = Llvm_bitreader.parse_bitcode llctx llmem in
Llvm.dump_module llm ;
()
EOF
compile it for bytecode
ocamlbuild -pkgs llvm,llvm.bitreader test.byte
or to the native code
ocamlbuild -pkgs llvm,llvm.bitreader test.native
run it
./test.native mycode.bc

MPI symbol lookup error: opal_uses_threads

SO: Ubuntu 17.04. Until yesterday everything was fine with MPI, then something went wrong. The error is the one on the the title and it comes out running with mpirun -n[n] ./myprogram.
Before Opal the error was with Libmpi.so.12 and I couldn't resolve it despite I tried indicating the LD_LIBRARY_PATH on my .bashrc, as suggested in similar questions here. Then reinstalling OpenMPI the error has changed in this new one, and I don't know how to fix it. Actually the result of apt-file search libmpi.so is:
lam4-dev: /usr/lib/lam/lib/libmpi.so
libopenmpi-dev: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so
libopenmpi2: /usr/lib/x86_64-linux-gnu/libmpi.so.20
libopenmpi2: /usr/lib/x86_64-linux-gnu/libmpi.so.20.0.2
libopenmpi2: /usr/lib/x86_64-linux-gnu/openmpi/lib/libmpi.so.20.0.2
And ldd returns:
linux-vdso.so.1 => (0x00007ffc415e5000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fe717956000)
libmpi.so.12 => not found
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe717738000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe717371000)
/lib64/ld-linux-x86-64.so.2 (0x000055ccd14f4000)
So the problem still seems to be libmpi.so.12 ? Before reinstalling OpenMPI, libmpi.so.12 was there, MPI couldn't find it, but was there.
[edit]
which mpirun returns:
/usr/bin/mpirun
And apt-file search mpicc returns:
lam4-dev: /usr/bin/mpicc.lam
lam4-dev: /usr/share/man/man1/mpicc.lam.1.gz
libmpich-dev: /usr/bin/mpicc.mpich
libmpich-dev: /usr/share/man/man1/mpicc.mpich.1.gz
libopenmpi-dev: /usr/bin/mpicc.openmpi
libopenmpi-dev: /usr/share/man/man1/mpicc.openmpi.1.gz
libsimgrid-dev: /usr/bin/smpicc
libsimgrid-dev: /usr/share/man/man1/smpicc.1.gz
mpich-doc: /usr/share/doc/mpich-doc/www1/mpicc.html
openmpi-common: /usr/share/openmpi/mpicc-wrapper-data.txt
openmpi-common: /usr/share/openmpi/mpicc.openmpi-wrapper-data.txt
it seems your application was built with an other MPI version (an older Open MPI or an other MPI library such as lam or mpich)
The easiest path is to rebuild your application with the freshly installed Open MPI
[EDIT]
this was diagnosed in the chat, and the root cause was system and user built Open MPI were inadvertently mixed.
once the environment was fixed so only the system Open MPI is used, the issue was resolved.

R v3.4.0-2 unable to find libgfortran.so.3 on Arch

I was just on vacation for a month so am unable to say the exact point at which this happened, but R from the official Arch repos is now unable to start, citing
/usr/lib64/R/bin/exec/R: error while loading shared libraries:
libgfortran.so.3: cannot open shared object file: No such file or directory
I thought that perhaps a symlink was improperly placed or destroyed, so I looked in /usr/lib to try to find it:
ls -halt /usr/lib/libgfortran.so.*
lrwxrwxrwx 1 root root 20 May 16 03:01 /usr/lib/libgfortran.so.4 -> libgfortran.so.4.0.0
-rwxr-xr-x 1 root root 7.1M May 16 03:01 /usr/lib/libgfortran.so.4.0.0
Has libfortran.so.3 been superseded by libgfortran.so.4 in Arch? If so, are there any possible workarounds for getting R to run with an older version?
pacman -Qi r
Name : r
Version : 3.4.0-2
Description : Language and environment for statistical computing and graphics
Architecture : x86_64
URL : http://www.r-project.org/
Licenses : GPL
Groups : None
Provides : None
Depends On : blas lapack bzip2 libpng libjpeg libtiff ncurses pcre readline zlib perl gcc-libs libxt libxmu pango xz desktop-file-utils zip unzip
Optional Deps : tk: tcl/tk interface [installed]
texlive-bin: latex sty files [installed]
Required By : None
Optional For : graphviz
Conflicts With : None
Replaces : None
Installed Size : 58.04 MiB
Packager : Evangelos Foutras <evangelos#foutrelis.com>
Build Date : Tue 25 Apr 2017 05:04:31 AM EDT
Install Date : Tue 20 Jun 2017 12:27:06 PM EDT
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
Edit: If anyone else comes across this, the r-devel AUR correctly compiles and runs, so hopefully on the next version bump the issue will be resolved.
Indeed, gfortran 7 bumps the ligfortran version to version 4. See http://gcc.1065356.n8.nabble.com/patch-fortran-PR77828-Linking-gfortran-7-compiled-program-with-libgfortran-of-5-x-allowed-but-crashes-td1311625.html It is not backwards compatible and some APIs have changed.
If you install an older version of gfortran you will get libgfortran.so.3. It is completely fine to have multiple versions in your system. Maybe there is a way how to rebuild R for version 4, but it will be possibly more work. See other answers how to rebuild the software https://stackoverflow.com/a/50744705/721644
I work on a software named pyferret which needs libgfortran.so.3. I am running fedora 27 whose package manager installs gfortran 7 (A higher version) by default. This produces the shared object libgfortran.so.4 in /usr/lib64. Another Linux system running Ubuntu 16.04.3, however has libgfortran.so.3. I copied it to my system in ~/pkgs/libs and ran the application as
export LD_PRELOAD=/home/vasu/pkgs/libs/libgfortran.so.3:/home/vasu/pkgs/libs/libopenblas.so.0;pyferret
This worked without the above error.
There are many packages in R dependent upon GCC Fortran. Some of those have not been updated to compile against the new GCC, while some package get updated that are dependent upon these, deldir and robustbase are two examples.
Check your warnings and are install any of the packages that fail to load then execute the upgrade.
The problem may come from some AUR packages that haven't been rebuild after the GCC update. In my personal case, it was probably the package openblas-lapack that messed around (see https://bbs.archlinux.org/viewtopic.php?id=236900). So there might be no need to install any former version of GCC.
What I did was to:
update all my AUR packages (yaourt -Syua)
then rebuild R (pacman -S r)
and it worked again.
This issue periodically occurs whenever libgfortran receives an incompatible soname bump, mostly because in the R world it is quite common for blas/lapack to be replaced by alternative implementations from the AUR.
The important thing to note here is that it is not actually R that has the error.
Minor disclaimer here: I'm speaking with my official Arch Linux bugwrangler hat on here, and this is how I would try to track down this sort of issue. (It's also how I check whether a bug report should be closed as invalid.)
Using my handy-dandy Arch Linux bugwrangler utility tool pkg-list-linked-libraries (it does what it says on the tin):
$ pkg-list-linked-libraries r libgfortran.so
==> checking linked libraries for r-3.5.1-2-x86_64.pkg.tar.xz ...
==> ERROR: No file in r-3.5.1-2-x86_64.pkg.tar.xz is linked to libgfortran.so
So, if it is not coming from R itself, where is it coming from? Using the tool lddtree (from pax-utils) to show not just the libraries needed by the executable (like ldd does), but to also show you, in tree format, why they are needed:
$ lddtree /usr/lib/R/bin/exec/R
/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
libR.so => /usr/lib/R/lib/libR.so
libblas.so.3 => /usr/lib/libblas.so.3
libgfortran.so.5 => /usr/lib/libgfortran.so.5
libquadmath.so.0 => /usr/lib/libquadmath.so.0
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1
libm.so.6 => /usr/lib/libm.so.6
libreadline.so.7 => /usr/lib/libreadline.so.7
libncursesw.so.6 => /usr/lib/libncursesw.so.6
libpcre.so.1 => /usr/lib/libpcre.so.1
liblzma.so.5 => /usr/lib/liblzma.so.5
libbz2.so.1.0 => /usr/lib/libbz2.so.1.0
libz.so.1 => /usr/lib/libz.so.1
libtirpc.so.3 => /usr/lib/libtirpc.so.3
libgssapi_krb5.so.2 => /usr/lib/libgssapi_krb5.so.2
libkrb5support.so.0 => /usr/lib/libkrb5support.so.0
libkeyutils.so.1 => /usr/lib/libkeyutils.so.1
libresolv.so.2 => /usr/lib/libresolv.so.2
libkrb5.so.3 => /usr/lib/libkrb5.so.3
libk5crypto.so.3 => /usr/lib/libk5crypto.so.3
libcom_err.so.2 => /usr/lib/libcom_err.so.2
librt.so.1 => /usr/lib/librt.so.1
libdl.so.2 => /usr/lib/libdl.so.2
libicuuc.so.62 => /usr/lib/libicuuc.so.62
libicudata.so.62 => /usr/lib/libicudata.so.62
libstdc++.so.6 => /usr/lib/libstdc++.so.6
libicui18n.so.62 => /usr/lib/libicui18n.so.62
libgomp.so.1 => /usr/lib/libgomp.so.1
libpthread.so.0 => /usr/lib/libpthread.so.0
libc.so.6 => /usr/lib/libc.so.6
The relevant bit here is the beginning:
/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
libR.so => /usr/lib/R/lib/libR.so
libblas.so.3 => /usr/lib/libblas.so.3
libgfortran.so.5 => /usr/lib/libgfortran.so.5
And if I delete the libgfortran library because this is a testing chroot and I don't care what happens to it, I see:
/usr/lib/R/bin/exec/R (interpreter => /lib64/ld-linux-x86-64.so.2)
libR.so => /usr/lib/R/lib/libR.so
libblas.so.3 => /usr/lib/libblas.so.3
libgfortran.so.5 => None
This clearly shows that it is libblas.so that has an error finding libgfortran.so, and from there you can check to see what pacman package owns the broken libblas.so -- and if it is truly an official repository package, then you can report a bug to get it fixed, if not, then now you know which AUR package to recompile yourself.
I can't say for sure about Arch-Linux, but multiple versions of the gfortran libraries are available on the standard set of repos included with apt on Ubuntu.
When changing to 18.04 (LTS) I had to install the previous version alongside the default version 4 of the libraries.
For me the following command solved this issue:
sudo apt-get install libgfortran3
Rebuilding all packages in R may not solve the issue if your package hasn't been maintained in a while, as was my case.

RODBC on OpenCPU can't find dependent libraries

There are a couple of related threads here, but the gist of my attempt to connect to Vertica with R over OpenCPU and vRODBC is:
I started with RJDBC, which works fine in RStudio (even the server RStudio edition), but OpenCPU/rApache doesn't like it. rJava on OpenCPU
I installed the vRODBC package which is a derivative of RODBC and I successfully queried Vertica from both the CMD Line using isql and from RStudio Server using the DSN and odbcConnect('myDSNName') Installing vRODBC
When I compile the app with code that works on RStudio Server I get a connection error when trying to run it over OpenCPU (pulled from the console):
It works from the RStudio Server
> vertica = odbcConnect("VerticaDSN")
> data = sqlQuery(vertica, query)
> data
TDIDCount
1 3015
But not from the Opencpu App I created
//From Console Output
[vRODBC] ERROR: state 01000, code 0, message [unixODBC][Driver Manager]Can't open lib '/opt/vertica/lib64/libverticaodbc.so.6.1.3' : file not found
Warning message:
ODBC connection failed
[1] -1
I checked this path and it clearly does exist. I found another question which says that this error is caused by a dependency that can't be loaded for the libverticaodbc.so library so I tried to follow steps to see which library I might not have had permissions for with the opencpu user to no avail. Can't open lib with UnixODBC
$ sudo su - opencpu
$ ldd /opt/vertica/lib64/libverticaodbc.so.6.1.3
linux-vdso.so.1 => (0x00007fff5cd10000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f16a30cc000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f16a2eb1000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f16a2c77000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f16a2a59000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f16a2755000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f16a244e000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f16a2238000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f16a1e73000)
/lib64/ld-linux-x86-64.so.2 (0x00007f16a4854000)
$
I'm close... very close... I can feel it... just gotta get some shadowy environment variable or permissions fixed so that OpenCPU can correctly find the ODBC drivers and then I'll have more R+webApp glory propelling me forward!

Resources