M
M
Mlkw2022-03-23 14:54:36
Python
Mlkw, 2022-03-23 14:54:36

How to transfer a tuple with variables to sqlite3?

I'm trying to transfer a list consisting of variables into a sqlite3 table, I found out that this can be done using JSON, but when converting string type variables to JSON and outputting them, they are represented in a numeric format. How can I fix this or are there other options for transferring a list / tuple with variables to the database?

mylist = [str(today),categor,name,count,summa]
print(mylist)
js = json.dumps(mylist)
print(js)

623b0a698e617169679623.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Nesterov, 2022-03-23
@Mlkw

Add ensure_ascii=False to dumps(...).
But as for me, storing a list in a relational database (including in the form of json) is a violation of the first normal form (see normalization ) and .
You need to either use nosql databases, which is 99% unjustified, or redesign the database so that each value is stored on a separate line.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question