SQLAlchemy SQLAlchemy


SQLAlchemy SQLAlchemy

Comparision

comparison with others

comparison with others

Reference

Session

Relation

Column

DATA TYPE

DATABASE URL

official

SCHEMA

dialect+driver://username:password@host:port/database

MySQL

# default
engine = create_engine('mysql://scott:tiger@localhost/foo')

# mysqlclient (a maintained fork of MySQL-Python)
engine = create_engine('mysql+mysqldb://scott:tiger@localhost/foo')

# PyMySQL
engine = create_engine('mysql+pymysql://scott:tiger@localhost/foo')

sqlite

# Unix/Mac - 4 initial slashes in total
engine = create_engine('sqlite:////absolute/path/to/foo.db')

# Windows
engine = create_engine('sqlite:///C:\\path\\to\\foo.db')

# Windows alternative using raw string
engine = create_engine(r'sqlite:///C:\path\to\foo.db')

# memory
engine = create_engine('sqlite://')