import sqlite3 as sl
con = sl.connect('kotenok-gav.db')
with con:
con.execute("""
CREATE TABLE CHAT (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
type TEXT,
authorid INTEGER,
message TEXT,
created TEXT
);
""")
con.execute("""
CREATE TABLE PLAYERS (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
accountid INTEGER
);
""")
con.execute("""
CREATE TABLE CHATNEW (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
type TEXT,
authorid INTEGER,
message TEXT,
created TEXT
);
""")
sql = 'INSERT INTO chat (id, type, authorid, message, created) values(?, ?, ?, ?, ?)'
data = [
(101, "typ1", 1, "msg1", "cre1"),
(102, "typ2", 2, "msg2", "cre2"),
(103, "typ3", 2, "msg3", "cre3"),
(104, "typ4", 3, "msg4", "cre4")
]
with con:
con.executemany(sql, data)
with con:
data = con.execute("SELECT * FROM chat")
for row in data:
print(row)
sql = 'INSERT INTO PLAYERS (id, accountid) values(?, ?)'
data = [
(1, 21),
(2, 22),
(3, 23)
]
with con:
con.executemany(sql, data)
with con:
data = con.execute("SELECT * FROM PLAYERS")
for row in data:
print(row)