六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 263|回复: 0

postgresql could not connect解决方法

[复制链接]

升级  12.67%

70

主题

70

主题

70

主题

举人

Rank: 3Rank: 3

积分
238
 楼主| 发表于 2013-1-30 01:40:06 | 显示全部楼层 |阅读模式
$python
>>> from sqlalchemy import *
>>> s= "postgres://root:root@localhost:5432/testing"
>>> engine   = create_engine( s )
>>> c = engine.connect()
......
sqlalchemy.exceptions.DBAPIError: (Connection failed) (OperationalError) could not connect to server: No route to host
        Is the server running on host "localhost" and accepting
        TCP/IP connections on port 5432?

1.
$vi /etc/postgresql/7.4/main/postgresql.conf
修改如下:
#tcpip_socket = false
tcpip_socket = true

2.
$ apt-get install python-psycopg2
或则
& apt-get install python-psycopg

结果如下:
>>> c = engine.connect()
>>>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表