Creating the user model

In order to store data about our users in Postgres, we first need to create a model that will define the fields and type of data we want to store.

We will first need to install two new Python packages: SQLAlchemy and Psycopg. SQLAlchemy is a toolkit and object-relational mapper that will serve as our gateway into the world of SQL. Psycopg is a PostgreSQL database adapter for Python.

Start by adding sqlalchemy (version 1.2.1 at the time of writing) and psycopg2 (version 2.7.4 at the time of writing) to your base.in file. From the root of your project folder, within your virtualenv, run:

$ pip-compile requirements/base.in
$ pip-sync requirements/base.txt requirements/test.txt

This will add sqlalchemy and psycopg2 to ...

Get Python Programming Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.