Skip to content

Commit

Permalink
Support reflection for encrypted databases
Browse files Browse the repository at this point in the history
  • Loading branch information
gordthompson committed Sep 28, 2021
1 parent 80ecb57 commit 8d5d747
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion sqlalchemy_access/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import pyodbc

__version__ = "1.1.1.dev0"
__version__ = "1.1.1"

pyodbc.pooling = False # required for Access databases with ODBC linked tables
_registry.register(
Expand Down
14 changes: 12 additions & 2 deletions sqlalchemy_access/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,12 @@ def get_pk_constraint(self, connection, table_name, schema=None, **kw):
db_engine = win32com.client.Dispatch(
self._get_dao_string(pyodbc_crsr)
)
db = db_engine.OpenDatabase(db_path)
db = db_engine.OpenDatabase(
db_path,
False,
True,
"MS Access;PWD={}".format(connection.engine.url.password),
)
tbd = db.TableDefs(table_name)
for idx in tbd.Indexes:
if idx.Primary:
Expand All @@ -803,7 +808,12 @@ def get_foreign_keys(self, connection, table_name, schema=None, **kw):
db_engine = win32com.client.Dispatch(
self._get_dao_string(pyodbc_crsr)
)
db = db_engine.OpenDatabase(db_path)
db = db_engine.OpenDatabase(
db_path,
False,
True,
"MS Access;PWD={}".format(connection.engine.url.password),
)
fk_list = []
for rel in db.Relations:
if rel.ForeignTable.casefold() == table_name.casefold():
Expand Down

0 comments on commit 8d5d747

Please sign in to comment.