Skip to content

Latest commit

 

History

History
77 lines (57 loc) · 3.33 KB

README.md

File metadata and controls

77 lines (57 loc) · 3.33 KB

Table of Contents

(Created by gh-md-toc)

Rationale

The idea is to minimize boilerplate code when doing the same things using native SQLite API. Only recurring usages are wrapped into helper classes or plain functions. Mixed uses of this module and the native API are expected. Always prefer bux::C_SQLite, bux::C_SQLiteStmt over sqlite3*, sqlite3_stmt* and you will be fine.

API Summary

Recurring Types and Their Safe Counterparts

Original Type Wrapper Class
sqlite3* bux::C_SQLite
sqlite3_stmt* bux::C_SQLiteStmt
  1. The right colum (class type) of each row above can be cast to the left column (native SQLite pointer type) implicitly & safely.
  2. bux::C_SQLite can only be constructed by a valid SQLite databse file name.
  3. bux::C_SQLiteStmt is contructed by passing a bux::C_SQLite instance and a SQL statement. And it is the recommended way to bind SQL arguments by calling native sqlite3_bind_\w+() functions before its own execute() method.

Installation

  1. Make sure you have installed yay or any other pacman wrapper.

  2. yay -S bux-sqlite to install. bux is also installed with it.

  3. yay -Ql bux-sqlite to see the installed files:

    bux-sqlite /usr/
    bux-sqlite /usr/include/
    bux-sqlite /usr/include/bux/
    bux-sqlite /usr/include/bux/oo_sqlite.h
    bux-sqlite /usr/lib/
    bux-sqlite /usr/lib/libbux-sqlite.a
    bux-sqlite /usr/share/
    bux-sqlite /usr/share/licenses/
    bux-sqlite /usr/share/licenses/bux-sqlite/
    bux-sqlite /usr/share/licenses/bux-sqlite/LICENSE
  4. Include the sole header file by prefixing the header name with bux/:

    #include <bux/oo_sqlite.h>

    p.s. Compiler is expected to search /usr/include by default.

  5. Make sure bux is also installed.

  6. If directly using gcc or clang is intended, the required compiler flags are -lbux-sqlite -lbux

from github in any of Linux distros

  1. Make sure you have installed cmake make gcc git sqlite, or the likes. Known package names in different distros/package-managers:

    Distro/PkgMngr Package Name
    ArchLinux/yay sqlite
    Fedora/dnf sqlite-devel
  2. git clone https://github.com/buck-yeh/bux-sqlite.git
    cd bux-sqlite
    cmake -D FETCH_DEPENDEES=1 -D DEPENDEE_ROOT=_deps .
    make -j
  3. Make sure bux is also installed or built.

  4. Include include/bux/oo_sqlite.h and link with src/libbux-sqlite.a & whereever-you-install-or-build-it/libbux.a