def initialize_db(config): url = URL( config["driver"], config["username"], config["password"], config["hostname"], None, config["database"], {'charset': 'utf8'}) # hack for sqlite databases url = str(url) engine = create_engine(url, encoding = config["encoding"], echo = config["echo"]) return engine def insert_into_database(): db = initialize_db(settings.DATABASE_ENGINE) db.echo = False connection = db.connect() metadata = MetaData(db) //Settings.py //Add your credentials DATABASE_ENGINE = { "driver": "", "hostname": "", "username": "", "password": "", "database": "", "encoding": "latin1", "echo": False }