Example #1
0
 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()
Example #2
0
 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()
Example #3
0
 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()
Example #4
0
 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()
Example #5
0
 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()
Example #6
0
    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()
Example #7
0
 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
Example #8
0
 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
Example #9
0
    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()
Example #10
0
 def createTable(self, name):
     cursor.execute(
         'CREATE TABLE IF NOT EXISTS {}(ID TEXT PRIMARY KEY, Count INTEGER)'
         .format(name))
     db.commit()
Example #11
0
 def __commit(self, sqlstring):
     print(sqlstring)
     my_cursor.execute(sqlstring)
     db.commit()