Esempio n. 1
0
def do_dump_tables():
    for stat in lucicat_utils.get_create_tables(db_prefix, "AUTO_INCREMENT"):
        print(stat)
    for stat in lucicat_utils.get_create_indexes(db_prefix):
        print(stat)
Esempio n. 2
0
    outname = sys.argv[2]

db_prefix = -1
i = 0
infile = open(inname, "rb")
for line in infile:
    #m = re.match(r"^INSERT INTO .sqlite_sequence. VALUES\('(.*)authors',", line)
    m = re.match(r"^CREATE TABLE (.*)books \(id", line)
    if m:
        db_prefix = m.group(1)
        break
    i += 1
    if i > 20:
        break
infile.close()
if db_prefix == -1:
    print("Error in input.")
    exit(-1)

outfile = sys.stdout
if outname:
    outfile = open(outname, "wb")

for stat in lucicat_utils.get_drop_tables(db_prefix):
    outfile.write(stat + "\n")
for stat in lucicat_utils.get_create_tables(db_prefix, "AUTO_INCREMENT"):
    outfile.write(stat + "\n")
for stat in lucicat_utils.get_create_indexes(db_prefix):
    outfile.write(stat + "\n")
lite2my.transform(inname, outfile, True)