h

hipp

v752f07blibrary

feature-packed SQLite driver

0 stars0 forksZlibupdated 9 months ago
Open repo

Hipp

A feature-packed SQLite driver

Warning

Only a subset of C API (sqlite3_*) is available at the moment.

Author is not actively testing Hipp outside of Windows, feel free to contribute (and maintain) support for macOS and Linux.

Motivation

Hipp was created as a fresh SQLite driver for use as storage in games and desktop applications. Package was named after D. Richard Hipp, the creator of SQLite database.

Getting Started

Run src\build.bat script to compile lib\sqlite3.lib

package demo

import "base:runtime"

import "core:fmt"
import "core:mem"
import "core:strings"

import "hipp"


main :: proc() {
	conn : ^hipp.Sqlite3
	err  : cstring

	hipp.sqlite3_open("demo.db", &conn)
	defer hipp.sqlite3_close(conn)

	hipp.sqlite3_exec(conn, `
CREATE TABLE IF NOT EXISTS MESSAGES(ID INT PRIMARY KEY NOT NULL, CONTENT TEXT NOT NULL);
INSERT OR IGNORE INTO MESSAGES (ID, CONTENT) VALUES (1, "Hello, World!");
	`, nil, nil, &err)

	msg : cstring = "No data"
	hipp.sqlite3_exec(conn, "SELECT ID, CONTENT FROM MESSAGES WHERE ID = 1", proc "c" (data: rawptr, count: u32, argv: ^cstring, envp: ^cstring) -> i32 {
		context = runtime.default_context()

		content    : ^string   = cast(^string)data
		col_values : []cstring = mem.slice_ptr(argv, cast(int)count)

		for i in 0..<count {
			col_value : string = col_values[i] != nil ? string(col_values[i]) : "<NULL>"

			if (mem.slice_ptr(envp, cast(int)count)[i] == "CONTENT") {
				content^ = strings.clone(col_value, context.allocator)

				break
			}
		}

		return 0
	}, &msg, &err)

	fmt.println(msg)
}
Package Info
Version
v752f07b
License
Zlib
Author
@Szydlo
Type
library
Forks
0
Created
9 months ago
Updated
9 months ago
Health
maintained
has releases
has readme
has license
Activity
last 56 weeks