Said's Blog

SQLite

April 27, 20243 min read
image

SQLite is a software library that provides a self-contained, serverless, zero-configuration, transactional SQL database engine. It is a popular choice for embedded database applications due to its small size, speed, and reliability. SQLite is widely used in mobile apps, IoT devices, and other small-to-medium scale applications where a full-fledged database server is not required.

What is SQLite?

SQLite is a relational database management system that is contained in a single disk file and does not require a separate server process. It is lightweight and easy to use, making it an excellent choice for applications that need a local database without the overhead of a full-scale database server.

Key features of SQLite
  • Self-contained: The entire database is stored in a single file, making it easy to deploy and manage.
  • Transaction support: SQLite supports ACID (Atomicity, Consistency, Isolation, Durability) transactions, ensuring data integrity.
  • Zero-configuration: There is no need for configuration or setup to start using SQLite in an application.
  • Cross-platform: SQLite is available on all major operating systems, making it a versatile choice for cross-platform applications.

Implementing SQLite in C#

implementation ways

There are diffent ways to use C# with a SQLite database.
There are high level options, like EntityFramework, which will help you work with your data like objects by writing c# to generate queries instead of wirting sql.
And there are low level options, like the most low level one 'ADO.NET'. By using this option, you will have to install the Microsoft.Data.Sqlite NuGet Package in order to handle database connection and database querying all on your own.

Example

This example, shows the Entity framework approach:

example-1_2
example-2_2

Conclusion

SQLite is a powerful and lightweight database engine that is well-suited for small-to-medium scale applications. With its self-contained nature and cross-platform support, SQLite is a versatile choice for a wide range of C# development projects.