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)
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)”)
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.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.