Setup PostgreSQL¶
We use PostgreSQL for Cliche in the production. PostgreSQL is the most powerful open-source relational database system in the world.
To build up your local development environment near production, we recommend you also to install PostgreSQL in your local box.
Install PostgreSQL¶
Mac¶
Postgres.app must be the easiest way to install PostgreSQL on your Mac. Go, download, and install.
Then, create a role and a database.
$ createuser -s `whoami`
$ createdb cliche_db -E utf8 -T postgres
Ubuntu/Debian Linux¶
Install it using APT, and then create a role and a database.
$ sudo apt-get install postgresql
$ sudo -u postgres createuser -s `whoami`
$ createdb cliche_db -E utf8 -T postgres
Connect from Python¶
Install psycopg2
using APT (if you’re on Ubuntu/Debian):
$ sudo apt-get install python-psycopg2
Or you can install it using pip, of course. However you have to install libpq (including its headers) and CPython headers to link first. These things can be installed using APT as well if you’re on Ubuntu or Debian:
$ sudo apt-get install libpq libpq-dev python-dev
Or yum if you’re CentOS/Fedora/RHEL:
$ sudo yum install postgresql-libs postgresql-devel python-devel
And then run pip:
$ pip install psycopg2
Configuration¶
DATABASE_URL = 'postgresql:///cliche_db'