[Tutor] Control MS Access with Python

Alan Gauld alan.gauld at yahoo.co.uk
Tue Feb 25 17:44:14 EST 2020


On 25/02/2020 17:01, Will Liu wrote:

> I already have pyodbc installed and have MS Access connected with Python IDLE. 
> Now I am able to read data through Python IDLE. Am I on the right way?

For your purposes yes. You can read the data you require from Access
using SQL commands and store the results in a Python collection
- a list of tuples say?

Then use the csv module to write those tuples into a CSV file that can
be read from excel.

If you need to be even cleverer with Excel (multi tabbed spreadsheet
for example) then there are 3rd party modules that can do it. But
for most purposes CSV is the easiest option.

You can finesse the queries in IDLE and then once you have them
exactly as you need transfer the code into a standalone script
that you can run as a monthly batch job generating all the
files automatically.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list