Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3345582
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:12:10+00:00 2026-05-18T01:12:10+00:00

I am using pyodbc to access an access (accdb) file. I want to add

  • 0

I am using pyodbc to access an access (accdb) file. I want to add an excel workbook into the access database programatically, but cannot find an API to do so. Here is my current code:

import pyodbc
DBFile = r'C:\Documents and Settings\IA.accdb'
conn = pyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb, *.accdb)};DBQ='+DBFile)

exFile = r'C:\Documents and Settings\IA_2006.xls'
conn1 = pyodbc.connect('DRIVER={Microsoft Excel Driver \ 
                       (*.xls)};DBQ='+exFile,autocommit=True)

cursor = conn.cursor()
####IA_1 is a table within IA.accdb
cursor.execute('select * from IA_1')
row = cursor.fetchone()
####For debugging, print a line
if row:
        print row

How should I import the data from the excel file (IA_2006.xls) into the IA.accdb?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:12:11+00:00Added an answer on May 18, 2026 at 1:12 am

    It seems like you got to a certain point and gave up.
    Don’t give up! 🙂

    You’ve made the connection to the Excel spreadsheet, now you need to read it*.

    curs1 = conn1.cursor()
    # the following returns list of tuples
    excel_results = curs1.execute('select [a_column]
                                   from [Sheet1$]').fetchall()
    

    Then you can insert to your MS Access db, e.g.:

    curs.executemany('insert into mytable (mycolumn) values (?)', excel_results)
    conn.commit()
    

    *If in doubt, Excel sheet names can be found by running the following:

    for row in curs1.tables():
        print row.table_name
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using pyodbc to data-mine a big database in a .mbd (access) file. I
So I'm using pyodbc to take a Date Time field from MS Access add
I have a standard django setup using postgres, but I also want to access
I'm using pyodbc with SQL Server 2000. I want to be able to insert
I have a setup using Pyodbc, UnixODBC and FreeTDS, but somewhere in there some
I am currently selecting a large list of rows from a database using pyodbc.
Periodically when using pyodbc to create a connection to an oracle database, it kills
I'm using pyodbc to query to an SQL Server database import datetime import pyodbc
I am using pyodbc, via Microsoft Jet, to access the data in a Microsoft
I'm using pyodbc to query a SQL Server 2008 database table with columns of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.