def __init__( self, dbDir=None, shows=None ) : ''' :param dbDir: Path to database directory :type dbDir: string or None :param shows: list of valid Shows in this database :type shows: list or None ''' self.dbDir = dbDir self.shows = shows self.currentDB = Database(self.dbDir, self.shows) self.currentDB.loadDB() self.updateDB = Database(self.dbDir)
def loadFiles(self): ## Load Databse (optionally with limits.) self.database = Database(self.dbDir, self.shows) self.database.loadDB() ## Add FileNames to folder. self.fileNames = [] for afile in os.listdir(self.path): if os.path.isfile(os.path.join(self.path, afile)): aFileName = FileName(afile, self.database) self.fileNames.append(aFileName)
def incrementalUpdate( self ) : """ Updates Database incrementally, not overwriting unless allowed. :rtype: None """ self.mergeDB = Database(self.dbDir) for newShow in self.updateDB.database : currentShow = self.currentDB.getShow( newShow ) if currentShow == None : self.mergeDB.addShow( newShow ) else : self.mergeDB.addShow( self.compareDetails( currentShow , newShow ) ) return self.mergeDB
f = "sonu monu manoj krishna mahesh ankit samarth".split() l = "sharma verma singh kapoor chadhdha".split() data = [[choice(f), choice(l), randint(20, 45)] for x in range(10)] # ------LOCAL--------- # user = Database( # dbkind="local", # dbpath="mydb.db", # dbmodule="sqlite3", # querymodule = "query" # ) #-------SERVER---------- user = Database( dbkind="server", dbmodule="mysql.connector", querymodule="query", host="remotemysql.com", port=3306, database="kmeSJcz0Au", user="******", password="******", ) #user.info() print('TABLE CREATED') if user.createtable() else print('TABLE NOT CREATED') #print('DATA INSERTED') if user.insertdata(data) else print('DATA NOT INSERTED') print(user.readdata(5))
from dbapi import Database user=Database( dbkind="local" dbpath="mypath.db" dbmodule="sqlite3" )