Answer the question
In order to leave comments, you need to log in
How to compare None Python and NULL SQLite?
I perform parsing with entering data into the database, some elements during parsing can be None, so they are sent to the database, while they are entered into the database as NULL. The problem is that before adding an element to the database, I check for its presence:
cursor = await db.execute('SELECT * FROM MATCHES WHERE (a="{}" AND b="{}" AND c="{}".format(a, b, c)))
INSERT INTO MATCHES (a, b, c) VALUES (?,?,?)', (a, b, c)
'SELECT * FROM MATCHES WHERE (a=? AND b=? AND c=?)', (a, b, c)
Answer the question
In order to leave comments, you need to log in
I solved the problem by replacing the = operator with IS
SELECT * FROM MATCHES WHERE (a IS ? AND b IS ? AND c IS ?)', (a, b, c)
And all because you need to use prepared statement! I suspect muscle zetcode.com/db/mysqlpython
Somewhere in between..
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question