从SQLITE3移动到PostgreSQL(PSQL(PostgreSQL的)9.4.5),我一直在使用sqlite3
访问sqlalchemy
数据库。我开发了一个pyramid
Web框架,并且sqlite3一直在工作。但是,我想从使用sqlite3
开始,而不是使用postgresql
作为db。我对此很陌生,并试图弄清楚我是否缺少一个步骤。
我在下载psycopg2
this tutorial跟随(添加它的setup.py)从改变development.ini
文件:
sqlalchemy.url = sqlite:////Users/ack/code/venv/NotssDB/notssdb/notssdb
到:
sqlalchemy.url = postgresql://ack:[email protected]:5432/notssdb
我使用的Mac OSX经由this site安装postgres的。
这样说,当我启动应用程序pserve development.ini
...数据库没有连接或加载。当我使用sqlite
网址时,数据库连接。
我可能会丢失什么?
development.ini 在金字塔:
sqlalchemy.url = postgresql://ack:[email protected]:5432/notssdb
# By default, the toolbar only appears for clients from IP addresses
# '127.0.0.1' and '::1'.
# debugtoolbar.hosts = 127.0.0.1 ::1
###
# wsgi server configuration
###
[server:main]
use = egg:waitress#main
host = 0.0.0.0
port = 5432
postgresql.conf
# - Connection Settings -
#listen_addresses = 'localhost' # what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
#port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
Postgres的服务器日志:
LOG: invalid length of startup packet
LOG: invalid length of startup packet
我必须改变postgres config file? (A stacks question指太)......我在pg_hba.conf
看到这个:
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 0.0.0.0/0 trust
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
#local replication ack trust
#host replication ack 127.0.0.1/32 trust
#host replication ack ::1/128 trust
使用的终端,这个我连接到数据库上的Postgres:
psql -h localhost -d notssdb -p 5432
新
postgresql服务器自动启动
如何启动金字塔应用程序:
$ python setup.py develop #installs packages
$ initialize_notssweb_db development.ini # --db Session--
$ pserve development.ini #terminal: --db Session-- Starting server in PID 3501. serving on http://0.0.0.0:5432
检查服务器:
$ pg_ctl -D /usr/local/var/postgres status
pg_ctl: server is running (PID: 701)
/usr/local/Cellar/postgresql/9.4.5/bin/postgres "-D" "/usr/local/var/postgres" "-r" "/usr/local/var/postgres/server.log"
可否请编辑该问题以包含“未加载”的相关错误消息,并检查PostgreSQL日志文件。 –
@MikkoOhtamaa我希望我有一个'不加载'提示...我收到'没有收到数据ERR_EMPTY_RESPONSE。无法加载网页,因为服务器未发送任何数据。“# – thesayhey
您需要获取Python追溯错误,而不是您的Web服务器所说的内容。它位于金字塔应用程序的控制台或日志文件中。 –