DEV Community

Mark Mahoney
Mark Mahoney

Posted on • Edited on

Programming with SQLite

This is a short introduction to writing programs that use SQLite. SQLite is one of my favorite programming tools. It is a full-featured relational database management system that runs 'in-process' in your favorite programming languages. This means that you do not have to have a separate database server running that your programs connect to. I am assuming the reader knows about Relational Database Management Systems (RDBMS) and SQL. This covers using SQLite in different programming languages.

You will be asked to follow along with the programs below. Just click on the links and a code playback page will load (you might want to open each one in a new tab). Then click on the comments on the left hand side of the playback screen or hit the play button to drive the development of the code. You can download the code at any point and run it on your machine. There are some controls in the top right hand side of the screen to make the text bigger or to switch to blog mode (which is good for small screens).

C++

I start by showing the C/C++ API. I go over some of the low level functions and then I build an abstraction layer on top of them. Finally, I explain transactions in SQLite.

Python and Flask

Next, I discuss SQLite in the context of Python. I show how to create tables and write queries from a standalone Python program. Next, I show how one can use SQLite in a Flask web app and how to create a web-based API.

Java

Lastly, I show how one can use SQLite from a Java program.

Comments and Feedback

You can find all of these code playbacks in my free 'mini-book', Programming with SQLite. I am always looking for feedback so please feel free to comment here or to send me a message. You can follow me on twitter @markm208.

Top comments (0)