Home>

I am thinking of processing to write data to Access after starting a python (32bit) program and processing it.
64-bit Access is required for the convenience of programs that are already running. (It is difficult to simply use 32-bit Access)
As the title says, is it possible to operate 64bit Access from 32bit Python?

We would appreciate it if you could borrow your knowledge.

pyodbc.InterfaceError: ('IM002','[IM002] [Microsoft] [ODBC Driver Manager] Data source name and specified default driver not found. (0) (SQLDriverConnect)')
What I tried
  1. It must be started with Python 3.7 (32bit) for module A which only works with the 32bit version of Python.
  2. My PC is a 64-bit version. (MS Access will also be a 64-bit version)
  3. Booting from the 64-bit version of Python works fine when only the processing of module A is removed. (I was able to write to Access)
  4. When booting from the 32-bit version of Python, the code will work when the database processing is removed. (Processing other than Access connection is possible)
  5. The modules required for Python for both bits have been imported.
Corresponding source code

The following is the code, although it will only be abbreviated and hidden.

import os
import shutil
import sys
import tkinter as tk
from tkinter import messagebox as msgbox
import pyodbc
# Module that works only in 32bit version
import A

root = tk.Tk ()
root.withdraw ()
filename = Corresponding file name
try: try:
    #####
    #Processing by module A goes here.
    #####
    NewFileName = filename [7: filename.find ("_", 8)]
    if os.path.exists (path +'\\' + filename) == True:
        msgbox.showwarning ('Error','A file with the same name already exists. \ nEnd processing.')
        root.quit ()
        sys.exit ()
    shutil.copy2 (filepath, path +'\\' + filename)
else: else:
    NewFileName = filepath [: filepath.rfind ("\\") + 1] +'done_' + filename
    if os.path.exists (NewFileName) == False:
        con_str ='Driver = {Microsoft Access Driver (* .mdb, * .accdb)};Dbq = Furupasu \\ Database Name.accdb;'
        con = pyodbc.connect (con_str) #Error here
        str_sql = "INSERT INTO table (num, T, U, C, U) VALUES ('" + value 1 + "','" + value 2 + "','" + value 3 + "','" + value 4 + "','" + value 5 + "')"
        con.execute (str_sql)
        con.commit ()
        con.close ()
        os.rename (filepath, NewFileName)
    elif os.path.exists (NewFileName) == True:
        msgbox.showwarning ('Error','File already exists. \ nPlease check.')
        root.quit ()
        sys.exit ()
Supplementary information
  • Python 3.7 (32bit)
  • Python 3.7 (64bit)
  • MS Access 64bit