October 2018
Intermediate to advanced
332 pages
8h 9m
English
Before we can abstract our data, we need to set up Flask SQLAlchemy. SQLAlchemy creates its database connection through a special database URI. This is a string that looks like a URL that contains all the information that SQLAlchemy needs to connect. It takes the general form of the following code:
databasetype+driver://user:password@host:port/db_name
For each driver that you installed previously, the URI would be as follows:
# SQLite connection string/uri is a path to the database file - relative or absolute.
sqlite:///database.db
# MySQL
mysql+pymysql://user:password@ip:port/db_name
# Postgres
postgresql+psycopg2://user:password@ip:port/db_name
# MSSQL
mssql+pyodbc://user:password@dsn_name
# Oracle
oracle+cx_oracle://user:password@ip:port/db_name ...