我正在尝试从我的ubuntu11.10连接另一个ubuntu pc中的postgres sql数据库。但我无法连接。我使用的是Python 2.6。
ConnDb.py:
import psycopg2.extensions
import sys
from time import time
def main():
tic = time()
username = "test"
DSN = "host=192.168.2.221 port=5432 dbname=ecateringsoft user=ecatering password=ecatering"
print "Connecting to database\n ->%s" % (DSN)
conn = psycopg2.connect(DSN)
cursor = conn.cursor()
cursor.execute("select * from details")
result = cursor.fetchall()
toc=time()
executiontime=toc-tic
if __name__ == "__main__":
main()
现在我遇到了这个错误,同时运行终端中的代码:
psycopg2.OperationalError: could not connect to server: No route to host
Is the server running on host "192.168.2.200" and accepting
TCP/IP connections on port 5432?
如我所知,我将listen_address =“localhost”更改为来自etc / postgresql / 9.1 / main / postgres.conf的listen_address =“192.168.2.200”
我按照建议检查了所有设置。一切都很好,但仍然得到错误。
etc / odbc.ini:
[FreeTDS]
Driver=FreeTDS_SAMPLE
Servername=SERVER_NAME
Description=FreeTDS SQL Server ODBC driver
Port=1433
Database=test
User=test
Password=test
ECT / obdcinit:
[FreeTDS]
Description=FreeTDS Driver
Driver=/usr/lib/odbc/libtdsodbc.so
Setup=/usr/lib/odbc/libtdsS.so
TDS_Version=8.0
请帮助。提前谢谢