Beispiel #1
0
def join(bot, user, *args):
    # Check if the person is already in the db, if the person is already in
    # dont add the person
    already_in_db = db.record(
        "SELECT UserID FROM users WHERE UserID = (?)", user['name']
    )
    if not already_in_db:
        # Person not in db add to db
        db.execute(
            "INSERT OR IGNORE INTO users (UserID, Membership) VALUES (?, ?)",
            user["name"],
            user['badges']
        )
        # Add person to csv file
        with open("./files/marbles.csv", "a+") as csv:
            for i in range(amount[user['badges']]):
                csv.writelines(f"{user['name']}\n")
        bot.send_message(f"Hey {user['name']} you are now in the game!")
Beispiel #2
0
 def execute(self, sql, args, format_input='qmark', paramstyle='pyformat'):
     db = self.db(paramstyle=paramstyle, format_input=format_input)
     db.connect()
     db.execute(sql, args)
     return db._conn.cursor_return.execute_kwargs[0]
Beispiel #3
0
 def test_execute_custom_cursor(self):
     db = self.db()
     db.connect()
     cur = db.cursor()
     db.execute("select 1", cur=cur)
     self.assertEqual("select 1", cur.execute_kwargs[0][0])
Beispiel #4
0
 def test_execute_internal_cursor(self):
     db = self.db()
     db.connect()
     db.execute("select 1")
     self.assertEqual("select 1",
                      db._conn.cursor_return.execute_kwargs[0][0])
Beispiel #5
0
 def execute(self, sql, args, format_input='qmark', paramstyle='pyformat'):
     db = self.db(paramstyle=paramstyle, format_input=format_input)
     db.connect()
     db.execute(sql, args)
     return db._conn.cursor_return.execute_kwargs[0]
Beispiel #6
0
 def test_execute_custom_cursor(self):
     db = self.db()
     db.connect()
     cur = db.cursor()
     db.execute("select 1", cur=cur)
     self.assertEqual("select 1", cur.execute_kwargs[0][0])
Beispiel #7
0
 def test_execute_internal_cursor(self):
     db = self.db()
     db.connect()
     db.execute("select 1")
     self.assertEqual("select 1", db._conn.cursor_return.execute_kwargs[0][0])