Python and SQLite: insert into table by input

Question:

enter image description here

I am doing this but it still gives me this Error

I am trying to insert data by input into the table

Asked By: Suliman

||

Answers:

Try this:

cr.execute(f"INSERT INTO Family VALUES('{name}',{age},'{Hobby}')")
Answered By: user56700

Python example to insert a single row into SQLite table
1.Connect to SQLite from Python. …
2.Define a SQL Insert query. …
3.Get Cursor Object from Connection. …
4.Execute the insert query using execute() method. …
5.Commit your changes. …
6.Get the number of rows affected. …
7.Verify result using the SQL SELECT query.

Answered By: Rajat Singh Rajput