...
/How to Create a Database and INSERT Some Data
How to Create a Database and INSERT Some Data
We'll cover the following...
Creating a database in SQLite is really easy, but the process requires that you know a little SQL to do it. Here’s some code that will create a database to hold music albums:
Press + to interact
import sqlite3conn = sqlite3.connect("mydatabase.db") # or use :memory: to put it in RAMcursor = conn.cursor()# create a tablecursor.execute("""CREATE TABLE albums(title text, artist text, release_date text,publisher text, media_type text)""")# This is SQLite's way of getting the tables created so farcursor.execute("SELECT name FROM sqlite_master WHERE type='table';")print(cursor.fetchall())
First we have to import the sqlite3 module and create a ...
Access this course and 1400+ top-rated courses and projects.