我有一个非常简单的python脚本,我尝试使用pyodbc连接到sqlite数据库:
#!/usr/bin/env python
import sqlite3
import pyodbc
con_str = 'DRIVER={SQLITE3};DATABASE=%s' % ('/tmp/test.db')
db = pyodbc.connect(con_str)
当我执行此脚本时,我收到错误:
Traceback (most recent call last):
File "./test.py", line 8, in <module>
db = pyodbc.connect(con_str)
pyodbc.Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib '/usr/lib64/libsqlite3odbc.so' : file not found (0) (SQLDriverConnect)")
/usr/lib64/libsqlite3odbc.so
是指向文件的链接:
$ ll /usr/lib64/libsqlite3odbc*
-rwxr-xr-x 1 root root 148232 Sep 29 2012 /usr/lib64/libsqlite3odbc-0.81.so
lrwxrwxrwx 1 root root 22 Aug 29 07:52 /usr/lib64/libsqlite3odbc.so -> libsqlite3odbc-0.81.so
以下是一些odbc文件:
$ cat /etc/odbc.ini
[SQLite3 Datasource]
Driver = SQLITE3
$ cat /etc/odbcinst.ini
[SQLITE3]
Description = SQLite ODBC 3.X
Driver = /usr/lib64/libsqlite3odbc.so
Setup = /usr/lib64/libsqlite3odbc.so
Threading = 2
FileUsage = 1
UsageCount = 1
已安装的版本(rpms):pyodbc-3.0.7-1.x86_64
,sqliteodbc-0.81-1.2.x86_64
。
我该怎么做才能消除这个错误?
答案 0 :(得分:1)
解决方案是安装0.9995版本的SQLite ODBC Driver。