Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sqlite3, Artemis_Kundennummerngenerator as custgen #, Artemis_Kunde as customer
- class ARTEMISDB():
- def __init__(self,accountnumber,PIN,value,currency,customerinfo):
- self.accountnumber = accountnumber
- self.PIN = PIN
- self.value = value
- self.currency = currency
- self.paramlist = [self.accountnumber,self.PIN,self.value,self.currency]
- self.customerinfo = customerinfo
- def connectDB(self):
- self.connection = sqlite3.connect("ARTEMIS_Database.db")
- self.cur = self.connection.cursor()
- def createDB(self):
- self.connectDB()
- customergen = custgen.CustomerGen()
- self.customernumbers = customergen.SQLCustomergenerator()
- self.createTable()
- # customerinformations = customer.CustomerInfo("PLACEHOLDER","PLACEHOLDER")
- # self.customerinfo = customerinformations.createList()
- # print self.customerinfo
- def checkDB(self):
- try:
- open("ARTEMIS_Database.db")
- print "Database found, loading tables"
- self.loadDB()
- except IOError:
- print "Database not found, creating one..."
- self.createDB()
- def createTable(self):
- self.cur.execute("""CREATE TABLE Customers (
- Name TEXT, Surname TEXT, Age TEXT, Customernumber TEXT)""")
- self.connection.commit()
- self.cur.execute("""CREATE TABLE Accounts (
- Accountnumber TEXT, PIN INTEGER, Value INTEGER, Currency TEXT)""")
- self.connection.commit()
- def loadDB(self):
- self.connectDB()
- def saveDB(self):
- pass
- def editDB(self):
- self.cur.execute("INSERT INTO Accounts VALUES (?,?,?,?)",self.paramlist)
- self.connection.commit()
- self.customerinfo.append(self.customernumbers[0])
- self.customernumbers.remove(self.customerinfo[3])
- self.cur.execute("INSERT INTO Customers VALUES (?,?,?,?)",self.customerinfo)
- self.connection.commit()
- if __name__=="__main__":
- list1 = ["Frost","Byte","17"]
- main = ARTEMISDB("DE001",1337,666,"EUR",list1)
- main.checkDB()
- main.editDB()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement