-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathcreate_premium_table.py
51 lines (43 loc) · 1.23 KB
/
create_premium_table.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import configparser
import datetime
import logging
import logging.handlers
import sqlite3
if __name__ == "__main__":
config = configparser.ConfigParser()
config.sections()
BOT_CONFIG_FILE = "kindle.conf"
config.read(BOT_CONFIG_FILE)
log_file = config["DEFAULT"]["logfile"]
db = config["SQLITE3"]["data_base"]
table = 'premium'
LOG_INFO_FILE = log_file
logger_info = logging.getLogger("InfoLogger")
logger_info.setLevel(logging.DEBUG)
handler_info = logging.handlers.RotatingFileHandler(
LOG_INFO_FILE, maxBytes=10240, backupCount=5, encoding="utf-8"
)
logger_info.addHandler(handler_info)
conn = sqlite3.connect(db)
cursor = conn.cursor()
aux = (
"""CREATE TABLE {} (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
chatid TEXT NOT NULL,
saldo TEXT);
"""
).format(table)
aux2 = ('''SELECT * FROM "{}"''').format(table)
try:
cursor.execute(aux)
logger_info.info(
str(datetime.datetime.now()) + " Tabela usuarios criada"
)
except:
cursor.execute(aux2)
usuarios = cursor.fetchall()
for user in usuarios:
print(user)
pass
conn.commit()
conn.close()