SQL and relational database basics
Before we can start using PostgreSQL with Python, you'll need to have at least a basic understanding of SQL. If you already have one, you can skip to the next section; otherwise, brace yourself for a super-short crash course on relational databases and SQL.
For over three decades, relational database systems have remained a de-facto standard for storing business data. They are more commonly known as SQL databases, after the Structured Query Language (SQL) used to interact with them.
SQL databases are made up of tables. A table is something like our CSV file, in that it has rows representing individual items and columns representing data values associated with each item. A SQL table has some important differences from our CSV file. First, each column in the table is assigned a data type which is strictly enforced; just as Python will produce an error when you try to use abcd
as an int
, a SQL database will complain if you try to insert letters into a numeric...