The MS Access database path was not accepted during deployment

Dear Sir
My code functions perfectly on the local host with MS Access Database using the specified path. However, during and after the deployment phase, it fails to recognize my database path and does not accept the connection string that includes this path. I kindly request you to review my code and provide the correct code that will enable my MS Access Database to operate successfully after deployment. Thank you in advance for your assistance.
see my code

import streamlit as st
import pyodbc
import pandas as pd
conn_str = ( ‘DRIVER={Microsoft Access Driver (*.mdb, *.accdb)} ; DBQ=.\TESTDB\mfa.accdb;’)

connm = pyodbc.connect(conn_str)
cursorm = connm.cursor()
query = “SELECT * FROM Payments”
dataf = pd.read_sql(query, connm)
mm = st.dataframe()
st.write(dataf)

1 Like

The path must be relative to the root of your repository.

thank you for your prompt reply
I have attempted all the suggested solutions, but the application continues to display the same error and does not run.
I have implemented the new code as per your insertion.
/mount/src/dblive/test668.py:5 in
2 import pyodbc
3 import pandas as pd
4 conn_str=(‘DRIVER={Microsoft Access Driver (.accdb)};DBQ=mfa.accdb;')
❱ 5 connm = pyodbc.connect(conn_str)
6 cursorm = connm.cursor()
7 query = “SELECT * FROM Payments”
8 dataf = pd.read_sql(query, connm)
Error: (‘01000’, "[01000] [unixODBC][Driver Manager]Can’t open lib 'Microsoft
Access Driver (
.accdb)’ : file not found (0) (SQLDriverConnect)")
2025-01-20 04:37:26.155 Uncaught app execution
Traceback (most recent call last):
File “/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/exec_code.py”, line 88, in exec_func_with_error_handling
result = func()
^^^^^^
File “/home/adminuser/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.py”, line 579, in code_to_exec
exec(code, module.dict)
File “/mount/src/dblive/test668.py”, line 5, in
connm = pyodbc.connect(conn_str)
^^^^^^^^^^^^^^^^^^^^^^^^
pyodbc.Error: (‘01000’, “[01000] [unixODBC][Driver Manager]Can’t open lib ‘Microsoft Access Driver (*.accdb)’ : file not found (0) (SQLDriverConnect)”)


see both error

That is not about the database path but about the Microsoft Access Driver, which is Windows only. I am not sure how or even if you can use your Access database in Debian. There is mdbtools, but I think it is only for reading.