import pyodbc
db_path = r'E:\MasterMindAcc\Sys\NetNo.accdb'
password = 'AaBbCc'
#Your connection string here...
conn_str = f'DRIVER={{Microsoft Access Driver (*.mdb, *.accdb)}};DBQ={db_path};PWD={password}'
try:
#Make the connection...
conn = pyodbc.connect(conn_str)
#Add your code for all your database operations here...
#Close the connection when done...
conn.close()
except Exception as e:
print(f"Error: {e}")
Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
OS.: Windows 11 IoT Enterprise (64-bit)
Python 3.12.0
Microsoft Access 2007 (32-bit)
print(pyodbc.drivers())
['SQL Server']
Want to Find a record in access 2007 database table where a user name is Admin and check where user typed password is correct or not but i am unable tpo conect access 2007 database to python
Just install
AccessDatabaseEngine_X64.exe /passive (which contains both the x86 and x64 version of the drivers) and you will be okay. Do not forget the /passive option because if you do it won't install unless you have MS Office 2010 installed as well. You can download the file from the Microsoft Access Database Engine 2010 Redistributable site
After you install AccessDatabaseEngine_X64.exe you should run the following code on your python shell to test everything's okay:
import pyodbc [x for x in pyodbc.drivers() if x.startswith('Microsoft')] and you should get a printout like
['Microsoft Access Driver (*.mdb, .accdb)', 'Microsoft Excel Driver (.xls, *.xlsx, *.xlsm, .xlsb)', 'Microsoft Access dBASE Driver (.dbf, *.ndx, .mdx)', 'Microsoft Access Text Driver (.txt, *.csv)']