Python Forum
Connect old access datbase .mdb
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connect old access datbase .mdb
#1
Hi, I need help, I'm trying to connect to an access database .mdb maybe from 2002,I am trying with pyodbc bat it tells me that the program is done whit older version.

code:

import pyodbc
conn = pyodbc.connect(r'Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=C:\Users\nio74\Desktop\dati.mdb;PWD=gmpa;')
cursor = conn.cursor()
Error:

pyodbc.Error: ('HY000', "[HY000] [Microsoft] [ODBC Microsoft Access Driver] Cannot open a database created with a previous version of the application. (-1019)


Some idea?

I have search driver OLEDB because i had made an application in PHP I was working with that driver, but I can't find for python
Reply
#2
You should probably use a database conversion program before writing your python code.
I found something that looks capable of doing that here: https://support.microsoft.com/en-us/offi...0cf7c11acd
Reply
#3
(Dec-12-2020, 04:42 PM)Larz60+ Wrote: You should probably use a database conversion program before writing your python code.
I found something that looks capable of doing that here: https://support.microsoft.com/en-us/offi...0cf7c11acd

unfortunately the database works on a management software and I cannot convert it otherwise the management software no longer works
Reply
#4
can you make a copy?
Reply
#5
i could find an old version of office and save it in a newer copy, but can i sync it with the old one later?
Reply
#6
Access was never a good DBMS it's been a mighty long time since i used it.
If you can rewrite the original code to use something better, sqlite would be good replacement for Access, but If a rewrite was in order, I'd choose PostgreSQL.

If you have to live with the legacy code, you might want to look at https://www.microsoft.com/en-us/download...x?id=13255 and implement into python.

This looks like just that: https://pypi.org/project/msaccessdb/

The same author that wrote above, also wrote an SQLAlchemy interface to MSAccess: https://pypi.org/project/sqlalchemy-access/
Reply
#7
I'm trying in every way even with the run time 2003 I can only open it with MDBplus opens. I post the database maybe I am incapable.

this is the database:

database
Reply
#8
I'm trying in every way even with the run time 2003 I can only open it with MDBplus opens. I post the database maybe I am incapable.

this is the database:

https://github.com/nio74/damndatabase

password gmpa
Reply
#9
I offer a case of beer to whoever succeeds Wall Wall Wall
Reply
#10
I don't know if this tool is available for windows, but seems to work on linux

you will need to install mdbtools:
  • open synaptic package manager (you mak have to install this package
  • click on edit-->search and search for mdbtools
  • if the checkbox is not showing green, click and accept all dependencies.
  • Also click on the mdbtools-doc
  • click apply and wait for install to finish

This is a command line tool, so next open a command window
the following commands are available:
Output:
Command Description ----------- ------------------------------------------------------- mdb-ver Prints the version (JET 3 or 4) of an mdb file. mdb-schema Prints DDL for the specified table. mdb-export Export table to CSV or SQL formats. mdb-json Export table to JSON format. mdb-tables A simple dump of table names to be used with shell scripts. mdb-count A simple count of number of rows in a table, to be used in shell scripts and ETL pipelines. mdb-sql A simple SQL engine (also used by ODBC and gmdb). mdb-queries List and print queries stored in the database. prcat Prints the catalog table from an mdb file. prkkd Dump of information about design view data given the offset to it. prtable Dump of a table definition. prdata Dump of the data given a table name. prole Dump of ole columns given a table name and sargs. mdb-hexdump (in src/extras) Simple hex dump utility that I've been using to look at mdb files.
with this tool, you can get a list of all tables, and dump them to CSV, SQL, or json I got a list of all tables using
mdb-tables dati.mdb > tablelist.txt

listed here:
Output:
Cartecredito certificati fattddt GarCalce GarRipaCalce immagini magqta negozio noteagg tabacc TabAcc2 TabCategorie TabCatSpese1 TabCatSpese2 TabCespiti tabcosto TabCstorico tabcv TabDettTrasporto tabgio tabinv TabIVA TabLavRipa tablic tabliv TabLogEventi tabmag tabmet TabModifica TabModPag tabogg TabPercSconti TabPos TabReferenze TabRFID tabric TabRientri TabRipaOgg TabRitiroMetallo tabsca TabSconti TabSetRipa TabSMS TabSpese TabTessere tabven TabVenditori TabVerificaDB Temp2SottoscortaXLS TempAnalisiForniXLS TempCatOIRXLS TempCLIXLS TempDaRiordinareCIPXLS TempIncassiXLS TempINVEXLS TempInvXLS TempMAGXLS TempMovMagXLS TempResiQta TempResoXLS TempRipaXLS TempRitiroMetalloXLS TempSottoscortaXLS TempVALANNOXLS TempVarAcquistiCZXLS TempVEN2XLS TempVENXLS tipipag DettVenduto immaR puntatori TabCarrelliOiR tabcli tabforni tablav TabLogUbi TabMovCarteCredito tabreso tabripa TabRipaUbi TabSettori TabUltimi TempAcquistiCZXLS TempDaRiordinareXLS TempMultidbCZXLS TempScadenXLS
the data can be exported to csv, sql or json

It looks like you can get an MS windows version here: https://sourceforge.net/projects/mdbtools/
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020