示例#1
0
def main():
    handle = DBConnection()

    queries = [
        "some",
        "sql",
        "queries",
        "here..."
    ]

    for query in queries:
        handle.add(query)

    handle.commit()

    print("\nDone")
示例#2
0
cur.execute("DROP TABLE IF EXISTS weapon_weareq ")
cur.execute(
    """CREATE TABLE weapon_weareq (
	guid INTEGER NOT NULL,
	ordernum INTEGER NOT NULL,
	typeid INTEGER NOT NULL,
	value INTEGER NOT NULL,
	CONSTRAINT weapon_weareq_ordernum_range CHECK (ordernum >= 1 AND ordernum <= 10),
	PRIMARY KEY (guid, ordernum),
	FOREIGN KEY (guid) REFERENCES weapon,
	FOREIGN KEY (typeid) REFERENCES sys_weareqtype (id)
)
"""
)

conn.commit()

records = romdb.decode_db(filedbfname, fields)
for k, v in records.items():
    if not db_fields.insert_fields(v):
        # constraint failure (no sys_name most likely) - skip the item
        continue

    for i in range(1, 7):
        abl = v["dropability" + str(i)]
        if abl != 0:
            cur.execute("INSERT INTO weapon_ability (guid, ordernum, abilityid) VALUES (%s,%s,%s)", (k, i, abl))

    for i in range(1, 11):
        typeid = v["eqtype" + str(i)]
        typeval = v["eqtypevalue" + str(i)]