pythonms-accesssqlalchemysqlalchemy-access

"Not a valid password" error when reflecting an encrypted Access database


i'm beginner in sqlalchemy, i want to reflect my table in database to object, but always return invalid password, even though the password is correct. I dont understand why this happend. When i try to inspect they return my table name, so my password, connection string or on create_engine is correct. when my database have no password is fine i can reflect it to Object, that's so weird. but why when i reflect database with password it's error, always return "Not a valid password" ??,

My MS. Access Tbl 1

My MS. Access Tbl 2

Error in Reflect but My Table name is returned

This is my Code

because I was curious I also made a test select data, and it turned out to be successful in retrieving the data

it's returned my data and success created connection

when i add some code for testing

I think all it's correct but why cannot reflect??, Please Help.

My Reference connection_string

My Reference SqlAlchemy Automap Reflect


Solution

  • I have just released sqlalchemy-access version 1.1.1 to address this issue. Note that as described in Getting Connected if you want to use a pass-through ODBC connection string with an encrypted database you need to supply the password in two places:

    driver = "{Microsoft Access Driver (*.mdb, *.accdb)}"
    db_path = r"C:\Users\Public\test\sqlalchemy-access\gord_test.accdb"
    pwd = "tiger"
    connection_string = (
        f"DRIVER={driver};"
        f"DBQ={db_path};"
        f"PWD={pwd};"
        f"ExtendedAnsiSQL=1;"
    )
    connection_uri = (
        f"access+pyodbc://admin:{pwd}@/"
        f"?odbc_connect={urllib.parse.quote_plus(connection_string)}"
    )
    engine = sa.create_engine(connection_uri)