Home > Net >  Python and SQLite: insert into table by input
Python and SQLite: insert into table by input

Time:01-03

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

CodePudding user response:

Try this:

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

CodePudding user response:

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.

  • Related