Python SQLite Tutorial: Complete Overview – Creating a Database, Table, and Running Queries

///Python SQLite Tutorial: Complete Overview – Creating a Database, Table, and Running Queries

Python SQLite Tutorial: Complete Overview – Creating a Database, Table, and Running Queries

FavoriteLoadingAdd to favorites

In this Python SQLite tutorial, we will be going over a complete introduction to the sqlite3 built-in module within Python. SQLite allows us to quickly get up and running with databases, without spinning up larger databases like MySQL or Postgres. We will be creating a database, creating a table, insert, select, update, and delete data. Let’s get started…

The code from this video can be found at:

✅ Support My Channel Through Patreon:

✅ Become a Channel Member:

✅ One-Time Contribution Through PayPal:

✅ Cryptocurrency Donations:
Bitcoin Wallet – 3MPH8oY2EAgbLVy7RBMinwcBntggi7qeG3
Ethereum Wallet – 0x151649418616068fB46C3598083817101d3bCD33
Litecoin Wallet – MPvEBY5fxGkmPQgocfJbxP6EmTo5UUXMot

✅ Corey’s Public Amazon Wishlist

✅ Equipment I Use and Books I Recommend:

▶️ You Can Find Me On:
My Website –
My Second Channel –
Facebook –
Twitter –
Instagram –

#Python

source

By |2019-05-14T18:59:16+00:00May 14th, 2019|Python Video Tutorials|41 Comments

41 Comments

  1. Jacob Cannon May 14, 2019 at 6:59 pm - Reply

    1:00 – Start of video
    1:38 – SQLite tutorial begins
    1:45 – Overview of the application to build

    2:10 – You need to create a "connection" variable to represent database
    2:22 – How and where to store your database
    2:38 – Using a filename to store your database
    3:47 – Creating a cursor (This allows you to execute sql commands)
    4:10 – Creating our table and the .execute() method
    4:15 – Creating the Employee table
    6:37 – Committing db changes and closing db connection

    7:45 – How to add data to db
    8:12 – INSERT INTO <table> VALUES() command
    8:45 – Query db for the employee we just added
    8:50 – Select statement
    8:50 – SELECT * FROM employees WHERE LAST='Shafer'
    9:35 – .fetchone(), .fetchmany(), .fetchall()
    11:12 – Adding another employee to the db and querying employee table

    12:19 – Start using the Employee class
    14:20 – Adding Python Employee() objects to db
    15:55 – Correct way to add Python objects to db
    16:01 – Option 1 (db API placeholder via ?)
    17:03 – Option 2 (db API placeholder via dictionary keys and values)

    22:57 – Prototyping CRUD functions
    23:42 – Insert employee function
    25:11 – Get employee
    26:03 – Update pay function and delete employee function

  2. Actually Programmer May 14, 2019 at 6:59 pm - Reply

    What should i do when it says no such column: last

  3. Jac Geo May 14, 2019 at 6:59 pm - Reply

    cur.execute("CREATE TABLE IF NOT EXISTS student(id INTEGER PRIMARY KEY, StdID text, Firstname text, Surname text,

    NameError: name 'cur' is not defined
    Can anyone help with this error?

  4. Zein El Mokhtar May 14, 2019 at 6:59 pm - Reply

    While True:
    Print(" Corey Schafer, YOU ARE MAKING THE WORLD A BETTER PLACE. Thank You Very Much ")

  5. James Patterson May 14, 2019 at 6:59 pm - Reply

    You had me at "SQLite is actually part of the standard library"!

  6. Adarsh kumar May 14, 2019 at 6:59 pm - Reply

    Bro please make your font slightly larger, useful videos but straining to see

  7. Jonathan Cardoso May 14, 2019 at 6:59 pm - Reply

    You're amazing! Got a new fan!

  8. rajivrjm May 14, 2019 at 6:59 pm - Reply

    Can you do more advanced python/database coding please? This is amazing

  9. Jim Ryan May 14, 2019 at 6:59 pm - Reply

    Just finished your Python Sqlite tutorial and would like to know is it possible using sqlite3 to open and have write and read privileges to and existing MS Access file on my computer. Tried using your example code but that did not work…thanks

  10. Brandon Null May 14, 2019 at 6:59 pm - Reply

    thank fuck

  11. diogo scoz May 14, 2019 at 6:59 pm - Reply

    is it possible to somehow call functions with queries created in python in sqlite command line like udf LENGTH?
    According to https://docs.python.org/2/library/sqlite3.html it's possible with create_function, but it seems like it doesnt work with functions with queries inside.

  12. Joel Montes de Oca May 14, 2019 at 6:59 pm - Reply

    Wonderful video, sent 10 BATS. Will check out SQLAlchemy now.

  13. Gicheru Murakaru May 14, 2019 at 6:59 pm - Reply

    Hey, you're amazing. But, could you please do all this but with Object Oriented Programming ?

  14. dhiraj bhasme May 14, 2019 at 6:59 pm - Reply

    Hi,
    Your video is awesome just want to know how we can fetch single list value of database after doing fetchall()

  15. Coolbloo May 14, 2019 at 6:59 pm - Reply

    Nice video. When I do this though, do I need to have anything installed besides python (like a MySQL database or something)?

  16. mustapha May 14, 2019 at 6:59 pm - Reply

    Excellent course. Thanks

  17. Олег Гайдуков May 14, 2019 at 6:59 pm - Reply

    you are the God from pedagogical IT universe, man

  18. azz Azm May 14, 2019 at 6:59 pm - Reply

    can you plz explain how to connect to mysql or any db in python…nd by the way ur my hero in python

  19. Anymynous Youtuber May 14, 2019 at 6:59 pm - Reply

    How to do full text search with sqlite3 with python…

  20. Mehul Chaudhari May 14, 2019 at 6:59 pm - Reply

    Thanks a lot !! Nice tutorial

  21. Carlos Brena May 14, 2019 at 6:59 pm - Reply

    Could you add a > if 'table employees' does not exist create it < or would that be bad practice?

  22. Sai Main May 14, 2019 at 6:59 pm - Reply

    Cool video, very helpful. Thanks!

  23. basirr payenda May 14, 2019 at 6:59 pm - Reply

    I have a question
    Why do we need .cursor() there?

  24. basirr payenda May 14, 2019 at 6:59 pm - Reply

    Very nice sir,
    I usually watch videos 2X speed, but for your videos even 1.3 is alot haha.
    and I like thatt

  25. Elisha Parsons May 14, 2019 at 6:59 pm - Reply

    I absolutely hate your background setup. It’s like reading through the fog.

  26. Joseph M Orost May 14, 2019 at 6:59 pm - Reply

    How do you fetch an Employee object from the database? Shouldn’t get_emps_by_name() return a list of Employee objects?

  27. UmeeX Gaming May 14, 2019 at 6:59 pm - Reply

    What is the editor he is using
    BTW Great Video mate thanks

  28. Roy Wang May 14, 2019 at 6:59 pm - Reply

    This is awesome!

  29. HashTagYTUser88 May 14, 2019 at 6:59 pm - Reply

    Thanks sir, you really helped out. Cheers!

  30. Xin Chen May 14, 2019 at 6:59 pm - Reply

    how do you execute the code

  31. Myles Gmail May 14, 2019 at 6:59 pm - Reply

    ty i tweeted this

  32. saeed sedigh May 14, 2019 at 6:59 pm - Reply

    you are the best!!

  33. Dennis Hardy May 14, 2019 at 6:59 pm - Reply

    Very good tutorial.

  34. Kamran Muazzam May 14, 2019 at 6:59 pm - Reply

    Breaks down things. Finally found a great video.

  35. Epicgamer7392 May 14, 2019 at 6:59 pm - Reply

    If I were to convert the list of tuples in c.fetchall() into a list of objects, how should I go about doing that? Should I, when creating an instance of the class Employee, have each element of the tuple as the arguments e.g. x = Employee(tuple[0], tuple[1], tuple[2]), or is there a better way of doing it?

  36. Oriental Melodies 2010 May 14, 2019 at 6:59 pm - Reply

    Your way of explaining the subject is outstanding!

  37. Abusayeed Roni May 14, 2019 at 6:59 pm - Reply

    What theme and color scheme are you using here?

  38. Marcellus Drum May 14, 2019 at 6:59 pm - Reply

    Thanks a lot. Really appreciate the effort, one of the best teachers I've seen!

  39. Youcef Yahiaoui May 14, 2019 at 6:59 pm - Reply

    Why! Super amazing teaching. I love Corey Schafer's tutorials.

  40. ismail houssaini May 14, 2019 at 6:59 pm - Reply

    Amazing tutorial. Thank you so much Corey

  41. 9876karthi May 14, 2019 at 6:59 pm - Reply

    Thank you for the wonderful tutorial

Leave A Comment

*