docs
This commit is contained in:
parent
99cd92fb4a
commit
52cf266a5e
@ -1,28 +0,0 @@
|
||||
:title
|
||||
SQLite
|
||||
|
||||
:sig
|
||||
SQLite
|
||||
|
||||
:see
|
||||
>types
|
||||
0_DValue
|
||||
0_StringMap
|
||||
sqlite_connect
|
||||
sqlite_query
|
||||
2_SQLite_connect
|
||||
2_SQLite_query
|
||||
2_SQLite_error
|
||||
2_SQLite_disconnect
|
||||
|
||||
:content
|
||||
SQLite connection wrapper for unit code. It opens database files, applies the runtime default pragmas, supports named parameters, and returns query rows as list-shaped `DValue` values.
|
||||
|
||||
```cpp
|
||||
SQLite db;
|
||||
if(db.connect("tmp/app.db")) {
|
||||
DValue rows = db.query("select * from notes");
|
||||
}
|
||||
```
|
||||
|
||||
Use exactly one SQL statement per `query()` call and named `:name` parameters.
|
||||
@ -1,18 +0,0 @@
|
||||
:sig
|
||||
bool SQLite::connect(String path)
|
||||
|
||||
:params
|
||||
path : database file path
|
||||
return value : true when the database opens and default pragmas apply
|
||||
|
||||
:see
|
||||
0_SQLite
|
||||
2_SQLite_error
|
||||
2_SQLite_disconnect
|
||||
|
||||
:content
|
||||
Opens or creates a SQLite database, registers the wrapper for request cleanup, sets a busy timeout, and applies default pragmas (`foreign_keys=ON`, WAL journal mode, synchronous NORMAL). On failure, details are available through `error()`.
|
||||
|
||||
```cpp
|
||||
SQLite db; if(!db.connect("tmp/app.db")) print(db.error());
|
||||
```
|
||||
@ -1,15 +0,0 @@
|
||||
:sig
|
||||
void SQLite::disconnect()
|
||||
|
||||
:params
|
||||
return value : none
|
||||
|
||||
:see
|
||||
0_SQLite
|
||||
|
||||
:content
|
||||
Forgets any worker-cache entry for this wrapper, closes the SQLite connection if open, clears the connection pointer, and unregisters it from request cleanup.
|
||||
|
||||
```cpp
|
||||
db.disconnect();
|
||||
```
|
||||
@ -1,16 +0,0 @@
|
||||
:sig
|
||||
String SQLite::error()
|
||||
|
||||
:params
|
||||
return value : current statement/connection error text, or an empty string
|
||||
|
||||
:see
|
||||
0_SQLite
|
||||
|
||||
:content
|
||||
Returns stored statement information when present; otherwise returns SQLite's current connection error message when connected.
|
||||
|
||||
```cpp
|
||||
DValue rows = db.query("select * from missing");
|
||||
print(db.error());
|
||||
```
|
||||
@ -1,19 +0,0 @@
|
||||
:sig
|
||||
DValue SQLite::query(String q)
|
||||
DValue SQLite::query(String q, const StringMap& params)
|
||||
|
||||
:params
|
||||
q : exactly one SQL statement
|
||||
params : named :name parameter values; missing keys bind NULL
|
||||
return value : result rows as a list-shaped DValue, or empty on error/non-row statements
|
||||
|
||||
:see
|
||||
0_SQLite
|
||||
2_SQLite_error
|
||||
|
||||
:content
|
||||
Prepares and runs exactly one SQL statement. Extra trailing SQL statements are rejected. Parameters must be named `:name` placeholders; positional `?` placeholders are rejected. Result rows are returned as a list of maps keyed by column name. Integer, float, text, blob, and null column types map to matching `DValue` representations where null leaves the field empty. After completion, `affected_rows`, `insert_id`, and `statement_info` are updated.
|
||||
|
||||
```cpp
|
||||
DValue rows = db.query("select * from users where id=:id", {{"id", "42"}});
|
||||
```
|
||||
Loading…
x
Reference in New Issue
Block a user