I am accessing a MS Access Database in Python 3.6 using pyodbc library. I can read a table, no problems. The I created a simple table (Employee). I inserted records. I was able to fetch the records too by reading the table, no problems.
I also listed the tables in the MS Access DB. Employee table shows in the list.
But when I open up the MS Access Database, I do not find the table. I changed MS Access DB to show hidden and system objects. Employee table doesn't show up.
What am I doing wrong?
Thanks
Here is the code:
I am accessing a MS Access Database (Windows Pro 10, MS Access 2013, 64 Bit) in Python 3.6 using pyodbc library. I can successfully make connection and read an existing table, no problems. Then I created a simple table (Employee). I inserted records, in python. I was able to fetch the newly added records by reading the table (executing SELECT * script ) within python program, no problems.
To be sure, in python program, I also listed the tables in the MS Access DB. Employee table shows in the list along with already existing and system tables.
But when I open up the MS Access Database, I do not find the table. I changed MS Access DB to show hidden and system objects, still employee table doesn't show up.
What am I doing wrong?
Thanks
Here is the code:
import pyodbc
db_file = r'''C:\TickData2018\StooqDataAnalysis.accdb'''
user ='admin'
password =''
odbc_conn_str ='DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=%s;UID=%s;PWD=%s'%\
(db_file, user, password)
conn = pyodbc.connect(odbc_conn_str)
print("connection made")
c = conn.cursor()
c.execute("SELECT * FROM 5MtsBaseForAnalysisSorted")
list1 = c.fetchmany(2)
print(list1[0][0])
print(list1[0][1])
print(list1[0][2])
try:
c.execute("""CREATE TABLE employee(
first text,
last text,
pay integer
);""")
exceptExceptionas e:
print(e)
conn.commit