Articles, forums, and SO Posts are abound on this topic.
Succinctly put, you cannot connect (at application level) a 64-bit Python.exe to a 32-bit MS Access ODBC driver (odbcad32.exe) since simply data is stored and processed differently between the types. However with backwards compatibility, it is advised to work in lowest common denominator as a 64-bit OS can run 32-bit applications and same level programs can "talk" to each other.
As for a dynamic setting to switch modes, this may be a very extensive workaround as the 32-bit python.exe and 64-bit python.exe are essentially distinct installed applications with packages like pypyodbc corresponding to each other. So above installing both versions, you would need to script with either:
- one python version that exits itself and calls other version using platform or variable length calculation as you mention with:
struct.calcsize("p")
;
- at command line (e.g., shell script, batch file);
- via external program (e.g., Excel/Access VBA, Java, C#, php.exe);
External applications will need to select which version will run the python script based on installed ODBC driver, looking at registry key as indicator, or variable type size. This may also require creating path variables to both python.exe versions and be assured they do not conflict with each other, selecting one as default.
Many choose to deploy two versions of application depending on users' CPU environment.