image-host-server/db/connector.py

18 lines
383 B
Python
Raw Normal View History

2022-03-11 18:09:49 +01:00
import os
from sqlalchemy import create_engine
user = os.environ['DB_USER']
password = os.environ['DB_PASSWORD']
host = os.environ['DB_HOST']
port = os.environ['DB_PORT']
database = os.environ['DB_DATABASE']
def get_connection():
return create_engine(
url="mysql+pymysql://{0}:{1}@{2}:{3}/{4}".format(
user, password, host, port, database
)
)