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.
You'd be better off using the mdbtools command mdb-tables.
mdb-tables test.mdb
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With