How to bring user id to the telegram in sqlite database?

How to make clicking /start id of the person is automatically recorded in the database sqlite?
June 5th 19 at 21:22
3 answers
June 5th 19 at 21:24
connection = sqlite3.connect("PATH")
cursor = connection.cursor()
cursor.execute("INSERT OR IGNORE INTO users (id) VALUES (:id)", {"id": id})

OR IGNORE in order to see if a user is already registered, nothing happened (otherwise it will error)

All this must be placed in a decorator that is responsible for the command /start. A good solution will also write a special class for a database not to open it every time.
, 1457937644123224991.jpg - misael41 commented on June 5th 19 at 21:27
June 5th 19 at 21:26
by the way, did you by chance here with this error?

sqlite3.InterfaceError: Error binding parameter :id - probably unsupported type.
Try to bring id to the line:
id = str(chat_info.id) - misael41 commented on June 5th 19 at 21:29
June 5th 19 at 21:28
SQLite for simple needs nothing different from mysql, if you are interested in syntax.

Find more questions by tags PythonBotsTelegram