How to install and use sqlobject + mysql on python hardware?

Is it possible to use sqlobject to connect to mysql database from python hardware? If so, how? What do i need to install?

I have sqlobject installed for cpython and it works fine, but if I use the same package in ironpython, I get "ImportError: No module named _mysql". I understand this means that ironpython cannot load the C-based DLLs needed to access the mysql API. What workaround, or is it?

+6
source share
4 answers

Looking at the sqlobject source code - this is pure python, the code depends on MySQLdb, which is limited by cpython.

However, if you change the code to use the mysql.connector library ( http://dev.mysql.com/doc/connector-python/en/index.html ), which is written in pure python, you should be able to establish a connection with mysql

Note. This mysql.connector does not follow the same api as MySQLdb, and will require a significant amount of rewriting to the source code.

I believe this may be your best decision.

+1
source

You need to install the "_mysql" module in python. I have no idea which version of python you are using.

Here are some links for installing the "_mysql" module for python 2.x or python 3.x

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

http://www.technicalbard.com/files/MySQL-python-1.2.2.win32-py2.6.exe

http://www.codegood.com/archives/129

-1
source

If you see this, you are probably mistaken when installing MySQLdb; re-read (or read) README. _mysql is a low-level C module that interacts with the MySQL client library.

Various versions of MySQLdb in the past have had problems building on "weird" platforms; “strange” in this case means “not Linux”, although usually on Unix / POSIX platforms, including BSD and Mac OS X, there are no problems. Windows was more problematic, in part because there was no mysql_config MySQL in the Windows installation. 1.2.1 solves most, if not all, of these problems, but you still have to edit the configuration file so that the configuration knows where to find MySQL and which libraries to include.

ImportError: libmysqlclient_r.so.14: cannot open shared object file: No such file or directory 

The number after .so may change, but this means that you have a version of MySQLdb compiled with one version of MySQL and are now trying to run it against another version. The shared library version tends to change between major releases.

Solution: restored MySQLdb or get the appropriate version of MySQL.

Another thing that can cause this: MySQL libraries may not be in your system path.

Solutions:

 set the LD_LIBRARY_PATH environment variable so that it includes the path to the MySQL libraries. set static=True in site.cfg for static linking reconfigure your system so that the MySQL libraries are on the default loader path. In Linux, you edit /etc/ld.so.conf and run ldconfig. For Solaris, see Linker and Libraries Guide. ImportError: ld.so.1: python: fatal: libmtmalloc.so.1: DF_1_NOOPEN tagged object may not be dlopen()'ed 

This is strange from Solaris. What does it mean? I have no idea. However, such things can happen if there is some inconsistency in the compiler or environment between Python and MySQL. For example, on some commercial systems you may have some code compiled with your own compiler, and other things compiled with GCC. They do not always connect together. One way to deal with this is to get binary packages from different vendors.

Decision. Reinstall Python or MySQL (or possibly both) from the source.

 ImportError: dlopen(./_mysql.so, 2): Symbol not found: _sprintf$LDBLStub Referenced from: ./_mysql.so Expected in: dynamic lookup 

This is one of Mac OS X. This seems to be a compiler mismatch, but this time between two different versions of GCC. It seems that almost every major release of GCC changes ABI in some cases, therefore, for example, linking code compiled with GCC-3.3 and GCC-4.0 can be problematic.

-1
source

Source: https://habr.com/ru/post/922085/


All Articles