db_table_names.py 503 B

12345678910111213141516171819
  1. """ db_table_names.py -- a simple demo for ADO database table listing."""
  2. import sys
  3. import adodbapi
  4. try:
  5. databasename = sys.argv[1]
  6. except IndexError:
  7. databasename = "test.mdb"
  8. provider = ['prv', "Microsoft.ACE.OLEDB.12.0", "Microsoft.Jet.OLEDB.4.0"]
  9. constr = "Provider=%(prv)s;Data Source=%(db)s"
  10. #create the connection
  11. con = adodbapi.connect(constr, db=databasename, macro_is64bit=provider)
  12. print('Table names in= %s' % databasename)
  13. for table in con.get_table_names():
  14. print(table)