Mike Driscoll Profile picture
I tweet about everything #Python Writing about Python @mousevspython @realpython Teaching at @TeachMePy Author of multiple books - https://t.co/MdP25zw5zQ

Feb 12, 2022, 8 tweets

It's the weekend, so now's a great time to talk about #Python and SQLite! 🐍

Python works with SQLite, a file-based database, right out of the box via its built-in `sqlite3` library.

Here's how you could connect to a SQLite database with Python:

When you use the `sqlite3` module in Python, you will be using regular SQL to work with it.

So to create a table, you would do something like this:

The following code shows how to insert one row of data into a table as well as how to insert multiple rows using SQL and sqlite3 in Python 🐍🔥

When it comes to querying your SQLite database with #Python, you will be using the normal SQL SELECT, FROM, WHERE, etc commands.

Here are a couple of examples:

Need to update your SQLite table record with #Python? Use the UPDATE SQL command!

If you want to remove a record from your SQLite database in PYthon, you would use the DELETE command just like you would with a regular SQL database:

If you'd like to learn more about working with SQLite in Python, check out my tutorial @mousevspython

blog.pythonlibrary.org/2021/09/30/sql…

@mousevspython Thanks for reading my thread on SQLite and Python.

Follow me for more great content on Python!

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling