我正在运行在 Fedora 14 x64 上加载的 mysql、pyodbc、python 2.7。
Odbcinst.ini 是:
# Example driver definitions
# Driver from the postgresql-odbc package
# Setup from the unixODBC package
#[PostgreSQL]
#Description = ODBC for PostgreSQL
#Driver = /usr/lib/psqlodbc.so
#Setup = /usr/lib/libodbcpsqlS.so
#Driver64 = /usr/lib64/psqlodbc.so
#Setup64 = /usr/lib64/libodbcpsqlS.so
#FileUsage = 1
# Driver from the mysql-connector-odbc package
# Setup from the unixODBC package
[MySQL]
Description = ODBC for MySQL
#Driver = /usr/lib/libmyodbc5.so
#Setup = /usr/lib/libodbcmyS.so
Driver64 = /usr/lib64/libmyodbc5.so
Setup64 = /usr/lib64/libodbcmyS.so
FileUsage = 1
odbc.ini 是:
[MySQL]
Driver = MySQL
Database = mysql
Server = localhost
Socket = /var/lib/mysql/mysql.sock
User = rooter
Password = sshh
mysql.sock 是空的?/var/lib/mysql/mysql.sock 有 0.B
python脚本是:
import pyodbc
#pyodbc.pooling = False
conn = pyodbc.connect('DRIVER={MySQL};SOCKET=/var/lib/mysql/mysql.sock;UID=rooter;PWD=sshh')
csr = conn.cursor()
csr.execute("SET GLOBAL event_scheduler = ON")
csr.close()
conn.close()
del csr
我似乎无法连接上面的脚本,使用 isql 我得到连接!
我的错误消息:
Traceback (most recent call last):
File "/CCX/Py/MySql Event OFF.py", line 4, in <module>
conn = pyodbc.connect('DRIVER={MySQL};SOCKET=/var/lib/mysql/mysql.sock;UID=rooter;PWD=sshh')
pyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnectW)')
在 Win XPx64 上,
#cxn = MySQLdb.connect (host = "localhost",user="rooter",passwd ="sshh")
错误消息:
File "C:\Python26\lib\site-packages\MySQLdb\__init__.py", line 19, in <module>
import _mysql
ImportError: DLL load failed: %1 is not a valid Win32 application.