diff options
-rw-r--r-- | dumpdbfields.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/dumpdbfields.py b/dumpdbfields.py new file mode 100644 index 0000000..131cfa3 --- /dev/null +++ b/dumpdbfields.py | |||
@@ -0,0 +1,33 @@ | |||
1 | from crodump import Database | ||
2 | import os | ||
3 | import os.path | ||
4 | from hexdump import asasc | ||
5 | |||
6 | class Cls: pass | ||
7 | |||
8 | def main(): | ||
9 | import sys | ||
10 | dbpath = sys.argv[1] if len(sys.argv)>1 else os.path.join(os.getenv("HOME"), "prj/cronos") | ||
11 | args = Cls() | ||
12 | args.verbose = False | ||
13 | |||
14 | for path, _, files in os.walk(dbpath): | ||
15 | if any(_ for _ in files if _.lower()=="crostru.dat"): | ||
16 | print(path) | ||
17 | |||
18 | db = Database(path) | ||
19 | for tab in db.enumerate_tables(): | ||
20 | tab.dump(args) | ||
21 | print("nr=%d" % db.nrofrecords()) | ||
22 | i = 0 | ||
23 | for rec in db.enumerate_records(tab): | ||
24 | # beware to skip tab.fields[0], which is the 'sysnum' | ||
25 | for field, fielddef in zip(rec, tab.fields[1:]): | ||
26 | print(">> %s -- %s" % (fielddef, asasc(field))) | ||
27 | i += 1 | ||
28 | if i>100: break | ||
29 | |||
30 | |||
31 | if __name__=="__main__": | ||
32 | main() | ||
33 | |||