src/debby/sqlite

Search:
Group by:
Source   Edit  

Public interface to you library.

Types

Statement = pointer
Source   Edit  

Consts

SQLITE_OK = 0
Source   Edit  
SQLITE_ROW = 100
Source   Edit  

Procs

proc checkTable[T: ref object](db: Db; t: typedesc[T])
Checks to see if table matches the object. And recommends to create whole table or alter it. Source   Edit  
proc close(db: Db) {....raises: [DbError], tags: [], forbids: [].}
Closes the database file. Source   Edit  
proc createIndexStatement[T: ref object](db: Db; t: typedesc[T];
    ifNotExists: bool; params: varargs[string]): string
Returns the SQL code need to create an index. Source   Edit  
proc createTableStatement[T: ref object](db: Db; t: typedesc[T]): string
Given an object creates its table create statement. Source   Edit  
proc dbError(db: Db) {.noreturn, ...raises: [DbError], tags: [], forbids: [].}
Raises an error from the database. Source   Edit  
proc insert[T: ref object](db: Db; obj: T)
Inserts the object into the database. Reads the ID of the inserted ref object back. Source   Edit  
proc openDatabase(path: string): Db {....raises: [DbError], tags: [], forbids: [].}
Opens the database file. Source   Edit  
proc query(db: Db; query: string; args: varargs[Argument, toArgument]): seq[Row] {.
    discardable, ...raises: [DbError, DbError], tags: [], forbids: [].}
Runs a query and returns the results. Source   Edit  
proc query[T](db: Db; t: typedesc[T]; query: string;
              args: varargs[Argument, toArgument]): seq[T]
Query the table, and returns results as a seq of ref objects. This will match fields to column names. This will also use JSONy for complex fields. Source   Edit  
proc sqlDumpHook(v: bool): string {....raises: [], tags: [], forbids: [].}
SQL dump hook to convert from bool. Source   Edit  
proc sqlite3_bind_text(stmt: Statement; index: int32; text: cstring;
                       size: int32; destructor: pointer): int32 {.importc,
    cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_close(db: Db): int32 {.importc, cdecl, ...raises: [], tags: [],
                                    forbids: [].}
Source   Edit  
proc sqlite3_column_blob(stmt: Statement; iCol: int32): pointer {.importc,
    cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_column_bytes(stmt: Statement; iCol: int32): int32 {.importc, cdecl,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_column_count(stmt: Statement): int32 {.importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc sqlite3_column_name(stmt: Statement; iCol: int32): cstring {.importc,
    cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_errmsg(db: Db): cstring {.importc, cdecl, ...raises: [], tags: [],
                                       forbids: [].}
Source   Edit  
proc sqlite3_finalize(stmt: Statement): int32 {.importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc sqlite3_last_insert_rowid(db: Db): int64 {.importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc sqlite3_open(filename: cstring; db: var Db): int32 {.importc, cdecl,
    ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_prepare_v2(db: Db; zSql: cstring; nByte: int32;
                        pStatement: var Statement; pzTail: ptr cstring): int32 {.
    importc, cdecl, ...raises: [], tags: [], forbids: [].}
Source   Edit  
proc sqlite3_step(stmt: Statement): int32 {.importc, cdecl, ...raises: [],
    tags: [], forbids: [].}
Source   Edit  
proc sqlParseHook(data: string; v: var bool) {....raises: [], tags: [], forbids: [].}
SQL parse hook to convert to bool. Source   Edit  
proc tableExists[T](db: Db; t: typedesc[T]): bool
Checks if table exists. Source   Edit  

Templates

template withTransaction(db: Db; body)
Transaction block. Source   Edit