Last active
September 6, 2021 13:18
-
-
Save gormih/3b8af6e72b86488d2b6204995650c7c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from win32com import client | |
def process_sql_in_mdb(mdb_file_path: str, sql: str): | |
''' | |
:param mdb_file_path: Full path to .mdb file | |
:param sql: sql query | |
:return: row set for db | |
''' | |
connection = client.Dispatch(r'ADODB.Connection') | |
row_set = client.Dispatch(r'ADODB.Recordset') | |
row_set.Cursorlocation = 3 | |
DSN = f'PROVIDER=Microsoft.ACE.OLEDB.12.0;DATA SOURCE={mdb_file_path};' | |
connection.Open(DSN) | |
row_set.Open(f'[{sql}]', connection, 1, 3) | |
row_set.MoveFirst() | |
return row_set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment