Yaho Where to make a note of cases that are no longer playable when playing sqlite db via python
There are ?
And :
payan.
It is used when there is only information on a specific column. (I don't want to specify all columns one by one)
query = ('INSERT INTO table (columnA) VALUES (:columnA)')
cursor.execute(query, {'columnA':'hogehoge'})
Somehow I saw it somewhere like ~~ : =
~~ ** =:
** ...
If you use this, can you do it regardless of the contents passed by parameters and the order?
query = ('INSERT INTO table (columnA, columnB) VALUES (columnA=:hogeA, columnB=:hogeB)')
cursor.execute(query, {'hogeB':'hogehoge'.'hogeA':'hogege'})
Addendum This is a solution that I noticed just by substituting the parameter of
:
(Additional note: may not be done)
Crane & to.> Using SQLite3 with Python3 – With sample code from basic operation to error handling Official Python guy stack overflow > sqlite-parameter-substitution-problem
If a field with the same content exists in a specific column, avoid only ID cover by pushing
INSERT INTO table (id, content) SELECT IFNULL(MAX(id), 0) + 1, content="hogegenoge" FROM table WHERE content
Recommended Posts