How to create an SQLite3 Database using Python

0 min

Every time we create a connection with the SQLite library we either connect to an existing Database or create it.

Here is the code

import sqlite3

# We create the connection to the example.db database
# If the database file is not there it is created.
con = sqlite3.connect('example.db')
How to create a database with SQLite3 using Python

Here, sqlite3.connect() function is going to look for a database file named example.db if it doesn't find it, it will create it.

Congratulation, you've successfully created an SQLite3 Database with Python