Moving from SQLITE3 to Postgresql (psql (PostgreSQL) 9.4.5) in Pyramid
I have been using sqlite3
to access a sqlalchemy
database. I have developed a pyramid
web framework and sqlite3 has been working. However, I wanted to move away from using sqlite3
and instead use postgresql
for the db. I am new to this and am trying to figure out if I am missing a step.
I followed this tutorial in downloading psycopg2
(adding it to setup.py) changing the development.ini
file from:
sqlalchemy.url = sqlite:////Users/ack/code/venv/NotssDB/notssdb/notssdb
to:
sqlalchemy.url = postgresql://ack:password@localhost:5432/notssdb
I installed postgres via this site using mac osx.
With that said, when I startup the app pserve development.ini
...the database is not connecting or loading. When I use the sqlite
url, the database connects.
What might I be missing?
development.ini in pyramid:
sqlalchemy.url = postgresql://ack:password@localhost: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 server log:
LOG: invalid length of startup packet
LOG: invalid length of startup packet
Do I have to change the postgres config file? (A stacks question refers to it too)... I saw this in 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
Using the terminal, this connects me to the DB on postgres:
psql -h localhost -d notssdb -p 5432
NEW
postgresql server is automatically launched
How I launch Pyramid app:
$ 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
Checking the server:
$ 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"