aminosbh / basic-sqlite-project

Basic C SQLite project that uses CMake as a build system. Demonstrates the usage of the SQLite C library. Mirror of https://gitlab.com/aminosbh/basic-sqlite-project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Basic SQLite project

This project is a basic C SQLite project that uses CMake as a build system.

It could be used as a base for any CMake/SQLite project. Just fork it, clone it and execute the rename_project.sh script. You will be prompted to enter the new project name, the new executable name and the new git repository, but you can keep the autodetected values. Finally, just commit and push the result to your repository.

## Overview

This project demonstrates the usage of the SQLite C library. It, first, tries to open the users.db SQLite database, and creates a new one if it does not yet exists. Then, it creates a user table, if it is not already created:

CREATE TABLE `user` (
    `id`            INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT UNIQUE,
    `first_name`    TEXT NOT NULL,
    `last_name`     TEXT NOT NULL,
    `birthday`      INTEGER,
    `email`         TEXT,
    `password`      TEXT
);

After that, it will prompt you to enter the number of users to be added (zero could be specified). If a positive value is entered, you should specify all details for each user.

Finally, it will display a table showing the full list of users, but just the columns first_name, last_name and birthday.

SQLite documentation:

GUI editor for SQLite databases:

DB Brwoser for SQLite is recommended for those who would like to edit their databases and verify that their code is working like they expect.

Dependencies

On Debian/Ubuntu based distributions, use the following command:

sudo apt install git build-essential pkg-config cmake cmake-data libsqlite3-dev

Build instructions

# Clone this repo
git clone https://gitlab.com/aminosbh/basic-sqlite-project.git
cd basic-sqlite-project

# Create a build folder
mkdir build
cd build

# Build
cmake ..
make

# Run
./basic-sqlite-project

Open the project with an IDE under Linux

See IDE_USAGE.md for details.

License

Author: Amine B. Hassouna @aminosbh

This project is distributed under the terms of the MIT license <LICENSE>.

About

Basic C SQLite project that uses CMake as a build system. Demonstrates the usage of the SQLite C library. Mirror of https://gitlab.com/aminosbh/basic-sqlite-project

License:MIT License


Languages

Language:C 54.1%Language:CMake 23.1%Language:Shell 22.7%