From 40b8b1b16a50360f6a6cbd7a65198f0414ce98bf Mon Sep 17 00:00:00 2001 From: itsme Date: Tue, 13 Jul 2021 21:19:25 +0200 Subject: example showing how to use db.enumerate --- dumpdbfields.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 dumpdbfields.py diff --git a/dumpdbfields.py b/dumpdbfields.py new file mode 100644 index 0000000..131cfa3 --- /dev/null +++ b/dumpdbfields.py @@ -0,0 +1,33 @@ +from crodump import Database +import os +import os.path +from hexdump import asasc + +class Cls: pass + +def main(): + import sys + dbpath = sys.argv[1] if len(sys.argv)>1 else os.path.join(os.getenv("HOME"), "prj/cronos") + args = Cls() + args.verbose = False + + for path, _, files in os.walk(dbpath): + if any(_ for _ in files if _.lower()=="crostru.dat"): + print(path) + + db = Database(path) + for tab in db.enumerate_tables(): + tab.dump(args) + print("nr=%d" % db.nrofrecords()) + i = 0 + for rec in db.enumerate_records(tab): + # beware to skip tab.fields[0], which is the 'sysnum' + for field, fielddef in zip(rec, tab.fields[1:]): + print(">> %s -- %s" % (fielddef, asasc(field))) + i += 1 + if i>100: break + + +if __name__=="__main__": + main() + -- cgit v1.2.3