Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get tables from .mdb using meza?

I'm using meza to read .mdb (MSAccess database) files.

from meza import io  

try:
    self.data = list(io.read_mdb(self.db_path, table=self.table))
except TypeError as e:
    raise

io.read_mdb returns generator object (if table param is specified it returns all rows from specified database if not from first). However - it also prints all table names to the console when I ran this code snippet.

QUESTION: Is there a way how to fetch all table names with meza? or Is there a way how to catch 'unwanted' tables console output?

i tried this, but without success:

with open(here_path + os.sep + "temp.txt", "w") as f:
    with redirect_stdout(f):
        try:
            x = list(io.read_mdb(path))
        except TypeError as e:
                raise

Then I would just read tables from file temp.txt

EDIT:

edit based on reubano answer:

def show_tables_linux(path):
    tables = subprocess.check_output(["mdb-tables", path])
    return tables.decode().split()

above function returns list of tables.

like image 205
scagbackbone Avatar asked Dec 21 '25 10:12

scagbackbone


1 Answers

You'd be better off using the mdbtools command mdb-tables.

mdb-tables test.mdb

like image 178
reubano Avatar answered Dec 23 '25 23:12

reubano



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!