Results 1 to 2 of 2
  1. #1
    karsun055 is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Jun 2018
    Posts
    1

    Post Can't see the table created by python through pyodbc



    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
    Last edited by pbaldy; 06-06-2018 at 03:37 PM. Reason: remove links

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 03-16-2017, 05:50 AM
  2. Replies: 3
    Last Post: 07-15-2016, 03:17 PM
  3. Access / Python Question
    By johnseito in forum Access
    Replies: 17
    Last Post: 07-10-2016, 05:06 PM
  4. RunApp to Open a python file
    By raytackettsells in forum Programming
    Replies: 1
    Last Post: 10-16-2013, 12:26 PM
  5. Replies: 31
    Last Post: 07-15-2012, 11:17 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums