Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Made by Matt (Ambler3) -
- #RUNNING THIS PROGRAM ONCE IS REQUIRED
- #BEFORE YOU START USING THE DROP LOGGER
- #IT WILL NOT WORK WITHOUT IT!
- import sqlite3
- def create_table(db_name,table_name,sql):
- with sqlite3.connect(db_name) as db:
- cursor = db.cursor()
- cursor.execute("select name from sqlite_master where name=?",(table_name,))
- result = cursor.fetchall()
- keep_table = True
- if len(result) == 1:
- response = input('The table {0} already exists, do you wish to recreate it (y/n): '.format(table_name))
- if response == 'y':
- keep_table = False
- print("The {0} table will be recreated - all existing data will be lost".format(table_name))
- cursor.execute("drop table if exists {0}".format(table_name))
- db.commit()
- else:
- print("The existing table was kept")
- else:
- keep_table = False
- if not keep_table:
- cursor.execute(sql)
- db.commit()
- #Creates the pre-set drop tables.
- def aa():
- sql = """create table SecondaryDrops
- (SecondaryDropID integer,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(SecondaryDropID))"""
- create_table(db_name,"SecondaryDrops",sql)
- def bb():
- sql = """create table Barrows2Drops
- (Barrows2DropID integer,
- Barrows2DropName text,
- Barrows2DropImage text,
- primary key(Barrows2DropID))"""
- create_table(db_name, "Barrows2Drops", sql)
- def cc():
- sql = """create table KKDrops
- (KKDropID integer,
- KKDropName text,
- KKDropImage text,
- primary key(KKDropID))"""
- create_table(db_name, "KKDrops", sql)
- def dd():
- sql = """create table NexDrops
- (NexDropID integer,
- NexDropName text,
- NexDropImage text,
- primary key(NexDropID))"""
- create_table(db_name, "NexDrops", sql)
- def ee():
- sql = """create table QBDDrops
- (QBDDropID integer,
- QBDDropName text,
- QBDDropImage text,
- primary key(QBDDropID))"""
- create_table(db_name,"QBDDrops" ,sql)
- def ff():
- sql = """create table VoragoDrops
- (VoragoDropID integer,
- VoragoDropName text,
- VoragoDropImage text,
- primary key(VoragoDropID))"""
- create_table(db_name, "VoragoDrops", sql)
- #Creates the tables for the drop logs.
- def gg():
- sql = """create table Barrows2Loots
- (Barrows2LootID integer,
- Barrows2DropName text,
- Barrows2DropImage text,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(Barrows2LootID)
- foreign key(Barrows2DropName) references Barrows2Drops(Barrows2DropName)
- foreign key(Barrows2DropImage) references Barrows2Drops(Barrows2DropImage)
- foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- create_table(db_name, "Barrows2Loots", sql)
- def hh():
- sql = """create table KKLoots
- (KKLootID integer,
- KKDropName text,
- KKDropImage text,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(KKLootID)
- foreign key(KKDropName) references KKDrops(KKDropName)
- foreign key(KKDropImage) references KK(KKDropImage)
- foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- create_table(db_name, "KKLoots", sql)
- def ii():
- sql = """create table NexLoots
- (NexLootID integer,
- NexDropName text,
- NexDropImage text,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(NexLootID)
- foreign key(NexDropName) references NexDrops(NexDropName)
- foreign key(NexDropImage) references Nex(NexDropImage)
- foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- create_table(db_name, "NexLoots", sql)
- def jj():
- sql = """create table QBDLoots
- (QBDLootID integer,
- QBDDropName text,
- QBDDropImage text,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(QBDLootID)
- foreign key(QBDDropName) references QBDDrops(QBDDropName)
- foreign key(QBDDropImage) references QBDDrops(QBDDropImage)
- foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- create_table(db_name, "QBDLoots", sql)
- def kk():
- sql = """create table VoragoLoots
- (VoragoLootID integer,
- VoragoDropName text,
- VoragoDropImage text,
- SecondaryDropName text,
- SecondaryDropImage text,
- primary key(VoragoLootID)
- foreign key(VoragoDropName) references VoragoDrops(VoragoDropName)
- foreign key(VoragoDropImage) references VoragoDrops(VoragoDropImage)
- foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- create_table(db_name, "VoragoLoots", sql)
- #If you wish to add a custom boss, please fill fill in this code with the correct boss names, if you want any additional bosses, just change the lettering (so def mm(): ... etc and add the relevant information in, you will also need to add to the main program to change stuff aswell.#
- #def ll():
- # sql = """create table BOSSNAMEDrops
- # (BOSSNAMEDropID integer,
- # BOSSNAMEDropName text,
- # BOSSNAMEDropImage text,
- # primary key(BOSSNAMEDropID))"""
- # create_table(db_name, "BOSSNAMEDrops", sql)
- #def mm():
- # sql = """create table BOSSNAMELoots
- # (BOSSNAMELootID integer,
- # BOSSNAMEDropName text,
- # BOSSNAMEDropImage text,
- # SecondaryDropName text,
- # SecondaryDropImage text,
- # primary key(BOSSNAMELootID)
- # foreign key(BOSSNAMEDropName) references BOSSNAMEDrops(BOSSNAMEDropName)
- # foreign key(BOSSNAMEDropImage) references BOSSNAMEDrops(BOSSNAMEDropImage)
- # foreign key(SecondaryDropName) references SecondaryDrops(SecondaryDropName)
- # foreign key(SecondaryDropImage) references SecondaryDrops(SecondaryDropImage))"""
- # create_table(db_name, "BOSSNAMELoots", sql)
- if __name__ == '__main__':
- print('This will create a blank database for you')
- print("This program should only be run ONCE")
- print("before using the drop logger, if you have")
- print("already got a 'DropTables.db' file, close this now!")
- print("You could overwrite all of your logs if you continue!")
- print("Input 'Y' to continue, any other input will close the program")
- input = input(">> ")
- if input == 'Y' or input == 'y':
- db_name = "DropTables.db"
- aa()
- bb()
- cc()
- dd()
- ee()
- ff()
- gg()
- hh()
- ii()
- jj()
- kk()
- #if you wish to add your own sections, please fill in the template above
- #add extra functions as needed, though more functions = larger database! :)
- #ll()
- #mm()
- else:
- print("Exiting.")
Advertisement
Add Comment
Please, Sign In to add comment