Databases

Overview

Parsons offers support for a variety of popular SQL database dialects. The functionality is focused on the ability to query and upload data to SQL databases. Each database class also includes the ability to infer datatypes and data schemas from a Parsons table and automatically create new tables.

Similar to other classes in Parsons, the query methods for databases all return Parsons Table, which allow them to be easily converted to other data types.

There is also support for synchronization of tables between databases as part of the Database Sync framework.

Google BigQuery

See Google for documentation.

MySQL

MySQL is the world’s most popular open source database. The Parsons class leverages on the MySQLdb1 python package.

Quick Start

Authentication

from parsons import MySQL

# Instantiate MySQL from environmental variables
mysql = MySQL()

# Instantiate MySQL from passed variables
mysql = MySQL(username='me', password='secret', host='mydb.com', db='dev', port=3306)

Quick Start

# Query database
tbl = mysql.query('select * from my_schema.secret_sauce')

# Copy data to database
tbl = Table.from_csv('my_file.csv') # Load from a CSV or other source.
mysql.copy(tbl, 'my_schema.winning_formula')

Postgres

Postgres is popular open source SQL database dialect. The Parsons class leverages the mysql python package.

Quick Start

Authentication

from parsons import Postgres

# Instantiate Postgres from environmental variables
pg = Postgres()

# Instantiate Postgres from passed variables
pg = Postgres(username='me', password='secret', host='mydb.com', db='dev', port=3306)

# Instantiate Postgres from a ~/.pgpass file
pg = Postgres()

Quick Start

# Query database
tbl = pg.query('select * from my_schema.secret_sauce')

# Copy data to database
tbl = Table.from_csv('my_file.csv') # Load from a CSV or other source.
pg.copy(tbl, 'my_schema.winning_formula')

Redshift

See Redshift for documentation.