コード例 #1
0
db = DB(config_file="sqlconfig.conf")

# create a database (must be the same as the one is in your config file)
database = "EventManagementDB"
if db.create_database(database=database, drop_database_first=True):
    print("Created database {}".format(database))
else:
    print("An error occurred while creating database {} ".format(database))

# create all the tables from databasemodel.sql
db.run_sql_file("EventManagementDB.sql")

# insert sample data from insert.sql
db.run_sql_file("insert.sql")

db.encrypt_passwords()

if int(db._transactions) == 1:
    db.run_sql_file("transactions.sql")
    print("\nSet up process finished with queries from transactions.sql")
else:
    print("\nSet up process finished")

tables = db.get_table_names()
show_menu()
option = int(input("Select one option from the menu: "))
while option != 7:
    if option == 1:
        option1(db, tables)  # create account
    elif option == 2:
        option2(db, tables)  # login