I am trying to insert a None
value into a row entry of my db. The table present
exists
db.execute("INSERT INTO present VALUES('test', ?, 9)", "This is a test!")
db.execute("INSERT INTO present VALUES('test2', ?, 10)", None)
but I get an error:
ValueError: parameters are of unsupported type
how do I insert a blank value for the second field in the row?
Syntax. Following is the basic syntax of using NULL while creating a table. SQLite> CREATE TABLE COMPANY( ID INT PRIMARY KEY NOT NULL, NAME TEXT NOT NULL, AGE INT NOT NULL, ADDRESS CHAR(50), SALARY REAL );
SQLite IS NOT NULL operator In this tutorial, you have learned how to check if values in a column or an expression is NULL or not by using the IS NULL and IS NOT NULL operators.
First, connect to the SQLite database by creating a Connection object. Second, create a Cursor object by calling the cursor method of the Connection object. Third, execute an INSERT statement. If you want to pass arguments to the INSERT statement, you use the question mark (?) as the placeholder for each argument.
Use a tuple, I.E.:
db.execute("INSERT INTO present VALUES('test2', ?, 10)", (None,))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With