con = sqlite3.connect('users.sqlite')
c = con.cursor()
c.execute("INSERT INTO users (cid,lang) VALUES ('%s','%s')"%(str(cid),0))
con.commit()
bot.send_message(adminid, "\xF0\x9F\x99\x87 New user: "+str(cid))
c.close()
con.close()
con = sqlite3.connect('users.sqlite')
c = con.cursor()
c.execute ("""UPDATE users SET lang = 1 WHERE cid="""+str(m.chat.id)+""" """)
c.close()
con.close()
import os
import sqlite3
db_filename = 'whatever.db'
schema = '''
CREATE TABLE users(
id INTEGER PRIMARY KEY autoincrement not null,
cid INTEGER,
lang INEGER default 1)
'''
cid = 12
db_is_new = not os.path.exists(db_filename)
with sqlite3.connect(db_filename) as conn:
if db_is_new:
conn.executescript(schema)
conn.execute("""
INSERT INTO users (cid, lang) VALUES (?, ?) """ ,
(cid, 0)
)
cursor = conn.cursor()
cursor.execute('select id, cid, lang from users')
for row in cursor.fetchall():
print(row)
print('update')
cursor.execute ("UPDATE users SET lang = 22 WHERE cid=?", (cid,))
print('after update')
cursor.execute('select id, cid, lang from users')
for row in cursor.fetchall():
print(row)