-
python mysql└ Mysql 2013. 6. 24. 14:39
python 에서 mysql DB 연결해야 하는데
소스 설치된 mysql 이였다.
python 에서 필요한 버젼의 so파일이 없었다;
그래서 결국 수동으로.. 핸들링..
경로를 잘못 잡아줬을때
]$ vi /root/.bash_profile
LD_LIBRARY_PATH=/mysql/lib
export LD_LIBRARY_PATH
]$ source /root/.bash_profile
]$ ldd /usr/lib64/python2.4/site-packages/_mysql.so
/usr/lib64/python2.4/site-packages/_mysql.so: /mysql/lib/libmysqlclient_r.so.15: no version information available (required by /usr/lib64/python2.4/site-packages/_mysql.so)
linux-vdso.so.1 => (0x00007fffd6aef000)
libmysqlclient_r.so.15 => /mysql/lib/libmysqlclient_r.so.15 (0x00002b9e086ca000)
]$ ./test.py
Traceback (most recent call last):
File "./test.py", line 20, in ?
cursor.execute('SELECT VERSION();')
File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 173, in execute
self.errorhandler(self, exc, value)
File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue
SystemError: NULL object passed to Py_BuildValue
Exception _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you can't run this command now") in <bound method DictCursor.__del__ of <MySQLdb.cursors.DictCursor object at 0x3afa3d0>> ignored
제대로 된 파일이 있는경로로 잡아줬을때
]$ vi /root/.bash_profile
LD_LIBRARY_PATH=/usr/lib64/mysql
export LD_LIBRARY_PATH
]$ source /root/.bash_profile
[root@cysparedb04 /home/willow]$ ldd /usr/lib64/python2.4/site-packages/_mysql.so
linux-vdso.so.1 => (0x00007fffe79fd000)
libmysqlclient_r.so.15 => /usr/lib64/mysql/libmysqlclient_r.so.15 (0x00002b39713fa000)
]$ ln -s libmysqlclient_r.so.15.0.0 libmysqlclient_r.so.15
]$ ./test.py
{'VERSION()': '5.5.8-log'}
'└ Mysql' 카테고리의 다른 글
mysql client version 이랑 DB version 다를때 (0) 2013.09.10 MySQL USING vs ON (0) 2013.05.09 php 호출시 mysql 소켓파일을 못찾을때 (0) 2012.09.06