awswrangler.db.get_engine

awswrangler.db.get_engine(db_type: str, host: str, port: int, database: str, user: str, password: str, **sqlalchemy_kwargs: Any) → sqlalchemy.engine.base.Engine

Return a SQLAlchemy Engine from the given arguments.

Only Redshift, PostgreSQL and MySQL are supported.

Parameters
  • db_type (str) – Database type: “redshift”, “mysql” or “postgresql”.

  • host (str) – Host address.

  • port (str) – Port number.

  • database (str) – Database name.

  • user (str) – Username.

  • password (str) – Password.

  • sqlalchemy_kwargs – keyword arguments forwarded to sqlalchemy.create_engine(). https://docs.sqlalchemy.org/en/13/core/engines.html

Returns

SQLAlchemy Engine.

Return type

sqlalchemy.engine.Engine

Examples

>>> import awswrangler as wr
>>> engine = wr.db.get_engine(
...     db_type="postgresql",
...     host="...",
...     port=1234,
...     database="...",
...     user="...",
...     password="..."
... )