Skip to content

Instantly share code, notes, and snippets.

@AlgorithmAlchemy
Last active June 29, 2023 10:50
Show Gist options
  • Save AlgorithmAlchemy/602f9bf08eed0b2fc45c4470121d129e to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/602f9bf08eed0b2fc45c4470121d129e to your computer and use it in GitHub Desktop.
sqlite3 заполнитель из txt
import sqlite3
import time
db = sqlite3.connect('users.sqlite')
connect = db.cursor()
f = open('text')
for line in f:
user_id = line
chat_id = line
bot_message_language = 0
language_code = None
day_limit = 50
sub_mission = 0
message_id = None
is_bot = 0
first_name = None
username = None
role = None
texts = None
type = "private"
inf_list = (user_id, chat_id, bot_message_language, language_code, day_limit, sub_mission, message_id, is_bot,
first_name, username, role, texts, type)
try:
connect.execute('''INSERT INTO users(user_id, chat_id, bot_message_language, language_code, day_limit,
sub_mission, message_id, is_bot, first_name, username, role, text, type)
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', inf_list)
db.commit()
except sqlite3.IntegrityError:
pass # если пользователь уже в базе пропускаем
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment