Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # returns if an item is in a user's notify list
- def pref_exists(userID, item):
- conn = psycopg2.connect("dbname={0} user={1} password={2} host={3}".format(config.mysql['db'], config.mysql['user'], config.mysql['passwd'], config.mysql['host']))
- cursor = conn.cursor()
- cursor.execute("SELECT count(item) from user_prefs where discordID = %s and item = %s", (str(userID), str(item)))
- data = cursor.fetchall()
- cursor.close()
- conn.close()
- return (data[0])[0] > 0
- # returns the list of preferences for a user
- def user_prefs(userID):
- conn = psycopg2.connect("dbname={0} user={1} password={2} host={3}".format(config.mysql['db'], config.mysql['user'], config.mysql['passwd'], config.mysql['host']))
- cursor = conn.cursor()
- cursor.execute("SELECT item FROM user_prefs WHERE discordID = %s", (str(userID),))
- data = cursor.fetchall()
- cursor.close()
- conn.close()
- return data
- # returns the list of users for an item
- def users(item):
- conn = psycopg2.connect("dbname={0} user={1} password={2} host={3}".format(config.mysql['db'], config.mysql['user'],
- config.mysql['passwd'],
- config.mysql['host']))
- cursor = conn.cursor()
- cursor.execute("SELECT DISTINCT discordID from user_prefs WHERE item = %s", (str(item),))
- data = cursor.fetchall()
- cursor.close()
- conn.close()
- return data
- # gets the server that a user is in
- def user_server(discordID):
- conn = psycopg2.connect("dbname={0} user={1} password={2} host={3}".format(config.mysql['db'], config.mysql['user'],
- config.mysql['passwd'],
- config.mysql['host']))
- cursor = conn.cursor()
- cursor.execute("SELECT DISTINCT server from user_prefs WHERE discordID = %s", (str(discordID),))
- data = cursor.fetchall()
- cursor.close()
- conn.close()
- print(data[0])
- return (data[0])[0].strip()
- def user_exists(discordID):
- conn = psycopg2.connect("dbname={0} user={1} password={2} host={3}".format(config.mysql['db'], config.mysql['user'],
- config.mysql['passwd'],
- config.mysql['host']))
- cursor = conn.cursor()
- cursor.execute("SELECT count(discordID) from user_prefs WHERE discordID = %s", (str(discordID),))
- data = cursor.fetchall()
- cursor.close()
- conn.close()
- return (data[0])[0] > 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement