Answer the question
In order to leave comments, you need to log in
How to add a new line?
Greetings, a small question:
There is a user base with an inv column, the inv column stores in itself:
{
"item90": 12,
"item3": 0,
"item60": 35,
"item21": 15
}
{
"item90": 12,
"item3": 0,
"item60": 35,
"item21": 15,
"newstroke": 0
}
Answer the question
In order to leave comments, you need to log in
import sqlite3
con = sqlite3.connect(':memory:')
data = [
["item90", 12],
["item3", 0],
["item60", 35],
["item21", 15]
]
con.execute('''create table if not exists inv
(items text, number integer)'''
)
def print_db(con):
for row in con.execute('select * from inv'):
print(row)
def add_data(con, query, data):
con.executemany(query, data)
con.commit()
query = 'INSERT into inv values (?, ?)'
add_data(con, query, data)
print_db(con)
print('\nadd newstroke\n')
data =
add_data(con, query, data)
print_db(con)
con.close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question