CREATE TABLE IF NOT EXISTS referals (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
code VARCHAR(36) NOT NULL, --Вот тут возможно будет тип UUID если база поддерживаетего
user_id VARCHAR(32) NOT NULL,
url VARCHAR(255),
used_counter INTEGER DEFAULT 0
)
UPDATE referals SET used_counter = used_counter +1 WHERE code = 'code'
code = [
["11072"],
["018"],
["13072", "13079"],
["0"],
["11070", "11012", "11219", "11071"],
["11464","11496", "11408"],
["136"]
]
num = [
["447BF01"],
["141AT01"],
["780AL01", "Z954CA"],
["0"],
["887AS01", "031AT01", "048BA01", "896AS01"],
["272BO01","278BO01", "687BM01"],
["308BO01"]
]
check= dict(zip([j for i in code for j in i],[j for i in num for j in i]))
if message.text in check:
print("{} equals {}".format(message.text,check[message.text]))
>>> code = [
["11072"],
["018"],
["13072", "13079"],
["0"],
["11070", "11012", "11219", "11071"],
["11464","11496", "11408"],
["136"]
]
>>> num = [
["447BF01"],
["141AT01"],
["780AL01", "Z954CA"],
["0"],
["887AS01", "031AT01", "048BA01", "896AS01"],
["272BO01","278BO01", "687BM01"],
["308BO01"]
]
>>> codes= [j for i in code for j in i]
>>> nums = [j for i in num for j in i]
>>> check = dict(zip(codes,nums))
>>> check["11072"]
'447BF01'
>>> "11072" in check
True
>>>
А теперь учитель требует объяснить код. Ваши действия?