我有麻烦pyodbc工作。我有unixodbc,unixodbc-dev,odbc-postgresql,pyodbc包安装在我的Linux Mint 14。
我失去了希望找到我自己的解决方案,任何帮助赞赏。详情如下:
原文链接:https://www.f2er.com/postgresql/193316.html我失去了希望找到我自己的解决方案,任何帮助赞赏。详情如下:
运行:
>>> import pyodbc >>> conn = pyodbc.connect("DRIVER={Postgresql};SERVER=localhost;DATABASE=test;USER=openerp;OPTION=3;")
给我:
>>> pyodbc.Error: ('IM002','[IM002] [unixODBC][Driver Manager]Data source name not found,and no default driver specified (0) (sqlDriverConnect)')
#odbcinst -j give:
unixODBC 2.2.14 DRIVERS............: /etc/odbcinst.ini SYSTEM DATA SOURCES: /etc/odbc.ini FILE DATA SOURCES..: /etc/ODBCDataSources USER DATA SOURCES..: /home/atman/.odbc.ini sqlULEN Size.......: 4 sqlLEN Size........: 4 sqlSETPOSIROW Size.: 2
这使我认为有一个unixodbc配置问题。
这里是我的unixodbc配置文件的内容:
文件/etc/odbcinst.ini:
[Postgresql ANSI] Description = Postgresql ODBC driver (ANSI version) Driver = psqlodbca.so Setup = libodbcpsqlS.so Debug = 0 CommLog = 1 UsageCount = 2 [Postgresql Unicode] Description = Postgresql ODBC driver (Unicode version) Driver = psqlodbcw.so Setup = libodbcpsqlS.so Debug = 0 CommLog = 1 UsageCount = 2
文件/etc/odbc.ini:
[Postgresql test] Description = Postgresql Driver = Postgresql ANSI Trace = No TraceFile = /tmp/psqlodbc.log Database = template1 Servername = localhost UserName = Password = Port = ReadOnly = Yes RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings =
文件〜/ .odbc.ini:
[DEFAULT] Driver = Postgresql [Postgresql] Description = Test to Postgres Driver = Postgresql Trace = Yes TraceFile = sql.log Database = nick Servername = localhost UserName = Password = Port = 5432 Protocol = 6.4 ReadOnly = No RowVersioning = No ShowSystemTables = No ShowOidColumn = No FakeOidIndex = No ConnSettings =