[PYTHON] Summary of SQLAlchemy connection method by DB

I want to use SQLAlchemy more conveniently

If you are using Python, I think you are using ** SqlAlchemy ** for DB processing without exception. However, SQLAlchemy is so unique that once you leave the project, you tend to forget the grammar.

To prevent this from happening this time, I'm always going to go back to this page and get started with SQLAlchemy right away.

SQLAlchemy DB connection method

URL of original material

The basic grammar is as follows. (For PostgreSQL)

from sqlalchemy import create_engine
engine = create_engine('dialect+driver://username:password@host:port/database')

Below is a list. User name, password and database name are tentative

# DB name Database URL
1 MySQL mysql://scott:tiger@localhost/foo
2 PostgreSQL postgresql://scott:tiger@localhost/mydatabase
3 SqLite sqlite:////absolute/path/to/foo.db'
4 Microsoft SQLServer(ODBC) mssql+pyodbc://scott:tiger@mydsn
4 Microsoft SQLServer(Pymssql) mssql+pymssql://scott:tiger@hostname:port/dbnam
5 Oracle oracle://scott:[email protected]:1521/sidnam

Change log

--2019/12/16 Newly created

Recommended Posts

Summary of SQLAlchemy connection method by DB
Summary of test method
SQLAlchemy + DB migration by Alembic
Summary of Proxy connection settings
Summary of basic implementation by PyTorch
Summary of restrictions by file system
Summary of gamma distribution parameter specification method
Summary of library hosting pages by language
Clustering of clustering method
[mypy] Summary of options not enabled by `--strict`
Python-peewee connection method
Numerical calculation of compressible fluid by finite volume method
[Language processing 100 knocks 2020] Summary of answer examples by Python
Speed comparison of each language by Monte Carlo method
Summary of Python articles by pharmaceutical company researcher Yukiya
[Python] Summary of table creation method using DataFrame (pandas)
[Summary of 27 languages] My number check digit calculation method
Implementation of DB administrator screen by Flask-Admin and Flask-Login
Visualization method of data by explanatory variable and objective variable
The copy method of pandas.DataFrame is deep copy by default
Numerical summary of data
parallelization of class method
Summary of Tensorflow / Keras
Summary of pyenv usage
Basic usage of SQLAlchemy
Summary of Python arguments
Summary of logrotate software logrotate
Reuse the behavior of the @property method by using a descriptor [16/100]