def printUrls(self): for url in Url.query.all(): print url print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
def printServers(self): for server in Server.query.all(): print server print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
def printMessages(self): for msg in Message.query.all(): print msg print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
def printChannels(self): for channel in Channel.query.all(): print channel for bot in channel.bots: print "\t%s" % bot print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
def printNetworks(self): for network in Network.query.all(): print network for server in network.servers: print "\t%s" % server print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
async def flakeReset(self, ctx): '''Resets the flakeRank (ADMIN).''' await ctx.send( "Are you sure you want to permanently reset the flakeRank? Type 'Y' to confirm." ) if not await self.confirmAction(ctx): await ctx.send('Reset aborted.') return cursor.execute('DROP TABLE IF EXISTS flake' + ctx.message.guild.id) db.commit()
def commit(self): try: db.commit() return True except IntegrityError as (statement): #Write out error print "IntegrityError \"{0}\" for {1}".format(statement.orig, statement.params) #Rollback db.rollback() #Raise new Exception if statement.connection_invalidated: print "Program error, connection invalidated to Database, quitting" return False
def flakeIncrement(self, ID, serverID): serverID = str(serverID) cursor.execute( 'UPDATE Flake' + serverID + ' SET Count = Count + 1 WHERE ID = ?', (ID, )) cursor.execute( 'INSERT OR IGNORE INTO flake' + serverID + ' (ID, Count) VALUES (?, 1)', (ID, )) cursor.execute('SELECT Count FROM Flake' + serverID + ' WHERE ID = ?', (ID, )) rtn = str(cursor.fetchone()[0]) db.commit() return rtn
def printBot(self, name=None): if name is not None: bots = Bot.query.filter(Bot.nick == name).all() else: bots = Bot.query.all() for bot in bots: print bot for server in bot.network.servers: print "on: \t%s" % server for channel in bot.channels: print "in: \t%s" % channel print "" #This seems like a hack to make sure we don't store any #references in memory which get used, modified later on db.commit()
def createTable(self, name): cursor.execute( 'CREATE TABLE IF NOT EXISTS {}(ID TEXT PRIMARY KEY, Count INTEGER)' .format(name)) db.commit()
def __commit(self, sqlstring): print(sqlstring) my_cursor.execute(sqlstring) db.commit()