db_table_names.py

Sample

Opens the same database & prints out a list of the tables in it.

Note

This sample uses the database \adodbapi\examples\test.mdb

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