Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. conn = psycopg2.connect(database=db_info.get('NAME'), user=db_info.get('USER'), password=db_info.get('PASSWORD'), host=db_info.get('HOST'), port=db_info.get('PORT'))
  2. c = conn.cursor()
  3. kom = "CREATE TABLE IF NOT EXISTS ch_{} (id INTEGER PRIMARY KEY, nickname VARCHAR)".format(chat_id)
  4. c.execute(kom)
  5. c.close()
  6. conn.close()
  7.  
  8. @bot.message_handler(commands=['register'])
  9. def reg_user(message):
  10. chat_id = str(message.chat.id)[1:]
  11. conn = psycopg2.connect(database=db_info.get('NAME'), user=db_info.get('USER'), password=db_info.get('PASSWORD'), host=db_info.get('HOST'), port=db_info.get('PORT'))
  12. c = conn.cursor()
  13. try:
  14. kom = "SELECT nickname FROM ch_{}".format(chat_id)
  15. curs = c.execute(kom)
  16. data = curs.fetchall()
  17.  
  18. File "D:/Programming/python/mason4pdabot/UselessBot.py", line 32, in reg_user
  19. curs = c.execute(kom)
  20. psycopg2.ProgrammingError: relation "ch_33578100" does not exist
  21. LINE 1: SELECT nickname FROM ch_33578100
Add Comment
Please, Sign In to add comment