mysql-python

How to check if a MySQL connection is open in Python?

家住魔仙堡 提交于 2020-05-11 07:22:34
问题 I am using MySQLdb (http://mysql-python.sourceforge.net/). It seems that connection.open and connection.sqlstate() do not work for me. Below is the code: def open(self): #TODO: check the connection's status # self.__conn.open OR self.__conn.sqlstate() try: print "sqlstate:"+str( self.__conn.sqlstate() ) print "open?"+str( self.__conn.open ) return "00000" == self.__conn.sqlstate() except Exception as e: print "Exception while checking MYSQL Connection:"+str(e) return False But when I ran

python mysqldb err on my mac :Library not loaded: @rpath/libmysqlclient.21.dylib

廉价感情. 提交于 2020-04-17 18:32:07
问题 import MySQLdb leads to Traceback (most recent call last): File "<stdin>", line 1, in <module> File "build/bdist.macosx-10.13-intel/egg/MySQLdb/__init__.py", line 19, in <module> File "build/bdist.macosx-10.13-intel/egg/_mysql.py", line 7, in <module> File "build/bdist.macosx-10.13-intel/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/simon/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.13-intel.egg-tmp/_mysql.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib

Python (1040, 'Too many connections')

夙愿已清 提交于 2020-04-08 08:11:51
问题 im newbie in Python. I have Item table with 3 attributes ( name, price, image) I want to get html from link and save to table. So i do that from books.models import Book, Author, Publisher, Item import urllib import gzip from StringIO import StringIO from BeautifulSoup import BeautifulSoup import MySQLdb as mdb def updateItems(request): con = mdb.connect('localhost', 'anhnt', '12', 'db_django'); cur = con.cursor() link = "http://pandagift.vn/i263/price1/qua-tang-doc-dao.htm" request = urllib

Python (1040, 'Too many connections')

爷,独闯天下 提交于 2020-04-08 08:08:11
问题 im newbie in Python. I have Item table with 3 attributes ( name, price, image) I want to get html from link and save to table. So i do that from books.models import Book, Author, Publisher, Item import urllib import gzip from StringIO import StringIO from BeautifulSoup import BeautifulSoup import MySQLdb as mdb def updateItems(request): con = mdb.connect('localhost', 'anhnt', '12', 'db_django'); cur = con.cursor() link = "http://pandagift.vn/i263/price1/qua-tang-doc-dao.htm" request = urllib

Error installing mysqlclient for python on Ubuntu 18.04

假装没事ソ 提交于 2020-03-17 11:18:06
问题 I installed Python 2.7.15rci and Python 3.6.7 on Ubuntu. When i did 'pip list' on virtualenv it returns me: Django (2.1.5) pip (9.0.1) pkg-resources (0.0.0) pytz (2018.9) setuptools (39.0.1) wheel (0.32.3) I'm trying to install mysqlclient (pip install mysqlclient) and returns an error. unable to execute 'x86_64-linux-gnu-gcc': No such file or directory error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 ---------------------------------------- Failed building wheel for

MySQLdb - ModuleNotFoundError

好久不见. 提交于 2020-03-03 12:39:40
问题 I'm failing at importing MySQLdb: import MySQLdb results in: ModuleNotFoundError: No module named 'MySQLdb' I installed the following: pip install mysql-python pip install mysqlclient apt-get install python3-dev python-pip python-dev libmysqlclient-dev apt-get install python-mysqldb (which according to this should suffice) Here is my pip freeze | grep -i sql : mysqlclient==1.3.13 MySQL-python==1.2.5 I'm using Python 3.6 with PyCharm Community Edition on a virtual machine Ubuntu 18.04 What is

pip安装mysql-python模块报错:cannot find -lmysqlclient_r

妖精的绣舞 提交于 2020-03-02 04:15:17
1.现象; gcc -pthread -shared -Wl,-z,relro build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64 -L/usr/lib64 -lmysqlclient_r -lpthread -lm -lrt -ldl -lpython2.7 -o build/lib.linux-x86_64-2.7/_mysql.so /usr/bin/ld: cannot find -lmysqlclient_r collect2: error: ld returned 1 exit status error: command 'gcc' failed with exit status 1 2. /usr/bin/ld: cannot find -lmysqlclient_r 这个可以看出是找不到mysqlclient_r文件或函数; 从现象的第一行看出是在/usr/lib64 路径下找mysqlclient_r 3.解决方法(copy文件到/usr/lib64/路径下): #cp /usr/lib64/mysql/libmysqlclient_r.a /usr/lib64/ 4.可以正常安装mysql-ptyhon #pip install mysql-python 来源: oschina 链接: https://my

MySQL rows delete when program exits

随声附和 提交于 2020-02-15 10:39:30
问题 I'm using Python and MySQLdb to add rows to my database. It seems that when my script exits, the rows get deleted. My last lines before the script exits do a "select *" on the table, which shows my one row. When I re-run the script, the first lines (after opening the connection) do the same "select *" and return zero results. I'm really at a loss here. I've been working for about 2 hours on this, and can't understand what could be accessing my database. Also, between running the scripts, I

MySQL rows delete when program exits

最后都变了- 提交于 2020-02-15 10:39:01
问题 I'm using Python and MySQLdb to add rows to my database. It seems that when my script exits, the rows get deleted. My last lines before the script exits do a "select *" on the table, which shows my one row. When I re-run the script, the first lines (after opening the connection) do the same "select *" and return zero results. I'm really at a loss here. I've been working for about 2 hours on this, and can't understand what could be accessing my database. Also, between running the scripts, I

GCC error when installing MySQL_python 1.2.2 (Mac OS 10.6 Snow Leopard)

馋奶兔 提交于 2020-02-07 06:34:12
问题 I'm trying to install MySQL_python 1.2.2 (I specifically need this version, not the current 1.2.3) on Snow Leopard, and getting this error below. Command to install: pip install -Iv http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.2/MySQL-python-1.2.2.tar.gz/download And a portion of the trace: copying MySQLdb/constants/CLIENT.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb/constants running build_ext building '_mysql' extension creating build/temp.macosx-10.6-universal-2