Ads by ProfitSence
Close

sqllite3 code example

Last Updated on Wednesday 5th Oct 2022

The most important data access language of all time.

  • If you have a slow computer or an extremely large data set
  • You can do all of these operations on data on disk.
  • I recommend using sqllite3 as the on-disk data storage engine.
  • Read the documentation for an explanation.

sqllite3 to create a database

Here's the example use of sqllite3

			
					import sqlite3

db_locale = 'users.db'

con = sqlite3.connect(db_locale)
c = con.cursor() #use to create commands

#command
c.execute(""" 
INSERT INTO questions (name, author, reviews) VALUES
('The Hobbit, or There and Back Again', 'J. R. R. Tolkien', 'There are very good characters and it's a brilliant story'),
('The Boy, the Mole, the Fox, and the Horse','Charlie Mackesy','A beautiful book with handwritten gems of wisdom about life, love, friendship along with lovely drawings.')
""")

#commit the changes
con.commit()
#close the database
con.close()