![]() ![]() |
Oct 15 2007, 04:02 PM
Post
#1
|
|
|
Group: Members Posts: 36 Joined: 29-March 05 Member No.: 6,732 |
I thought I'd try out the Python/PyQt/MySQL combination, but I've hit a snag that I can't handle. Any words of wisdom would be very welcome.
The machine is a C3000 with stock ROM. I installed the Zaurus Python Image v2.4 from pyqplayer.sourceforge.net: files python-exe_2.4.0-1_arm.ipk python24.ex2.gz Python runs fine, as far as I can tell. For MySQL, I installed mysql_3.23.49-8.7_arm.ipk That works fine using the mysql app: as zaurus or root I can create and populate databases. No passwords set yet. But from python, I can't connect to MySQL. I've created a test database called 'junk' and here's what happens when I try to access it. $ python Python 2.4 (#1, Jan 5 2005, 19:21:20) [GCC 2.95.1 19990816 (release)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import qt >>> import MySQLdb >>> ms = MySQLdb.connect(host='localhost',user='zaurus',db='junk',passwd='') Traceback (most recent call last): File "<stdin>", line 1, in ? File "/home/QtPalmtop/lib/python2.4/site-packages/MySQLdb/__init__.py", line 64, in Connect return Connection(*args, **kwargs) File "/home/QtPalmtop/lib/python2.4/site-packages/MySQLdb/connections.py", line 109, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)") >>> The MySQL daemon is running (or the mysql app wouldn't have worked). The directory /var/run/mysqld is empty. There are no error reports in dmesg. Running as root gives the same error. I'm totally new to Python, and I've no idea what to try next. Cheers and TIA John |
|
|
|
Oct 16 2007, 12:13 PM
Post
#2
|
|
|
Group: Members Posts: 36 Joined: 29-March 05 Member No.: 6,732 |
Apologies for bumping my own post, but after more searching I found the answer and I thought I'd post it in case anyone else should get bitten.
The Python code was looking for the connection socket as /var/run/mysqld/mysql.sock, but the directory was empty. In /etc/mysql/my.cnf, the socket location was given as /tmp/mysql.sock and indeed that socket file exists. So the solution was to add: unix_socket='/tmp/mysql.sock' as an extra parameter to the MySQLdb.connect() call. Magic. Hope that helps someone. |
|
|
|
Oct 16 2007, 01:10 PM
Post
#3
|
|
|
Group: Members Posts: 668 Joined: 3-December 03 From: US Member No.: 1,034 |
Thanks for putting in the solution to your own problem ..
It could help someone tomorrow ... so thanks. |
|
|
|
Jan 9 2008, 02:10 PM
Post
#4
|
|
|
Group: Members Posts: 1 Joined: 9-January 08 From: Stanford, CA Member No.: 21,175 |
|
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 23rd May 2013 - 06:19 PM |