SQLite core API access.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public, | parameter | :: | DB_TRANS_DEFERRED | = | 0 |
Deferred transaction (default). |
integer, | public, | parameter | :: | DB_TRANS_IMMEDIATE | = | 1 |
Start a new write immediately (may fail with |
integer, | public, | parameter | :: | DB_TRANS_EXCLUSIVE | = | 2 |
No reading while transactions are underway. |
Generic bind function.
Binds 64-bit real value to statement. Returns E_DB_BIND
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Value index. |
||
real(kind=r8), | intent(in) | :: | value |
Value. |
Binds 32-bit integer value to statement. Returns E_DB_BIND
on
error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Value index. |
||
integer(kind=i4), | intent(in) | :: | value |
Value. |
Binds 64-bit integer value to statement. Returns E_DB_BIND
on
error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Value index. |
||
integer(kind=i8), | intent(in) | :: | value |
Value. |
Binds query parameters to SQLite statement. Returns E_DB_BIND
on
binding error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
type(db_query_type), | intent(inout) | :: | db_query |
Database query type. |
Binds string value to statement. The value will be trimmed before
binding. Returns E_DB_BIND
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Value index. |
||
character(len=*), | intent(in) | :: | value |
Value. |
Generic routine to return number of rows changed.
The function returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement on the database connection. Auxiliary changes caused by triggers, foreign key actions or REPLACE constraint resolution are not counted.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
integer(kind=i4), | intent(out) | :: | n |
Number of changes. |
The function returns the number of rows modified, inserted or deleted by the most recently completed INSERT, UPDATE or DELETE statement on the database connection. Auxiliary changes caused by triggers, foreign key actions or REPLACE constraint resolution are not counted.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
integer(kind=i8), | intent(out) | :: | n |
Number of changes. |
Generic column function.
Returns string value from column of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
character(len=:), | intent(out), | allocatable | :: | value |
Value. |
Returns double value from column of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
real(kind=r8), | intent(out) | :: | value |
Value. |
Returns 32-bit integer value from column of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
integer(kind=i4), | intent(out) | :: | value |
Value. |
Returns 64-bit integer value from column of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
integer(kind=i8), | intent(out) | :: | value |
Value. |
Returns string value from column of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
character(len=*), | intent(inout) | :: | value |
Value. |
||
integer, | intent(out) | :: | n |
Actual string length. |
C-interoperable callback function that is invoked on error
SQL_BUSY
. May return 0 to signal that no more invocations are
desired.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in), | value | :: | client_data |
Client data. |
|
integer(kind=c_int), | intent(in), | value | :: | n |
Number of times the busy callback has been invoked previously. |
Returns value.
Callback routine that is invoked if passed to dm_db_backup()
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | remaining |
Remaining pages. |
||
integer, | intent(in) | :: | page_count |
Total number of pages. |
C-interoperable callback routine that is invoked for each created SQLite log.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in), | value | :: | client_data |
Client data. |
|
integer(kind=c_int), | intent(in), | value | :: | err_code |
SQLite error code. |
|
type(c_ptr), | intent(in), | value | :: | err_msg_ptr |
SQLite error message. |
C-interoperable callback routine that is invoked on database updates.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(c_ptr), | intent(in), | value | :: | client_data |
Client data. |
|
integer(kind=c_int), | intent(in), | value | :: | type |
Database operation. |
|
type(c_ptr), | intent(in), | value | :: | db_name |
Database name. |
|
type(c_ptr), | intent(in), | value | :: | table_name |
Table name. |
|
integer(kind=c_int64_t), | intent(in), | value | :: | row_id |
Row id. |
SQLite database connectivity type.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(c_ptr), | public | :: | ctx | = | c_null_ptr |
C pointer to SQLite 3 database. |
|
logical, | public | :: | read_only | = | .false. |
Read-only flag. |
SQLite database statement type.
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
type(c_ptr), | public | :: | ctx | = | c_null_ptr |
C pointer to SQLite 3 statement. |
Attaches the database at path
to the current connection. If no name
is passed for the attached database, the name will be set to
attached
. The function trims the given path and name strings.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in) | :: | path |
Path of database to attach. |
||
character(len=*), | intent(in), | optional | :: | name |
Name of attached database. |
Starts a transactions in IMMEDIATE mode. Mode shall be either
DB_TRANS_DEFERRED
, DB_TRANS_IMMEDIATE
, or DB_TRANS_EXLCUSIVE
.
Default is DB_TRANS_IMMEDIATE
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
integer, | intent(in), | optional | :: | mode |
Transaction mode. |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt | |||
integer, | intent(in) | :: | index |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt | |||
integer, | intent(in) | :: | index |
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt | |||
integer, | intent(in) | :: | index |
Commits a transaction. Returns E_DB_EXEC
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
Detaches database from the current connection. If no name is passed
for the attached database, the name is assumed to be attached
. The
function trims the given name string. Returns E_DB_DETACH
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in), | optional | :: | name |
Name of attached database. |
Returns last database error as DMPACK error code, optionally the
SQLite error code in argument sqlite_error
. This function matches
an SQLite error code to the corresponding DMPACK error code. For
example, if the last SQLite error is SQLITE_OK
, the function
returns E_NONE
.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
integer, | intent(out), | optional | :: | sqlite_error |
SQLite error code. |
Returns last SQLite error message.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
Error message.
Executes given query, and returns optional error message if rc
is
not E_NONE
. Otherwise, err_msg
is not allocated. Returns
E_DB_EXEC
on error
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in) | :: | query |
SQL query. |
||
character(len=:), | intent(out), | optional, | allocatable | :: | error_message |
Optional error message. |
Initialises SQLite backend. Returns E_DB
on error.
Returns .true.
if database type has associated pointer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
Returns .true.
if database is in read-only mode. This function
checks only the opaque database type for the read-only flag. It is
still possible to enable ready-only access by calling
dm_db_set_query_only()
. The function dm_db_get_query_only()
returns the status of the query_only
pragma.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
Returns true if SQLite 3 was compiled threadsafe.
Prepares database statement. Returns E_DB_PREPARE
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
character(len=*), | intent(in) | :: | sql |
SQL query. |
Jumps back to a save point. Returns E_DB_EXEC
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in) | :: | name |
Save point name. |
Resets database statement. The function returns E_DB
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
Rolls a transaction back, optionally to save point name
. The
function returns E_DB_ROLLBACK
is the rollback failed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in), | optional | :: | name |
Save point name. |
Creates a save point name
. Returns E_DB_EXEC
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
character(len=*), | intent(in) | :: | name |
Save point name. |
Sets SQLite busy callback that is invoked whenever the database is busy.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
procedure(dm_db_busy_callback) | :: | callback |
Callback function. |
|||
type(c_ptr), | intent(in) | :: | client_data |
C pointer to client data. |
Sets SQLite busy timeout in msec. Returns E_DB
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
integer, | intent(in) | :: | msec |
Timeout in mseconds. |
Sets SQLite error log callback. The dummy argument client_data
is
passed to the callback routine. The function returns E_DB
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
procedure(dm_db_log_callback) | :: | callback |
Callback routine. |
|||
type(c_ptr), | intent(in), | optional | :: | client_data |
C pointer to client data. |
Sets SQLite error log callback. The dummy argument client_data
is
passed to the callback routine. The function returns E_DB
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_type), | intent(inout) | :: | db |
Database type. |
||
procedure(dm_db_update_callback) | :: | callback |
Callback routine. |
|||
type(c_ptr), | intent(in), | optional | :: | client_data |
C pointer to client data. |
Finalises SQLite handle. Returns E_DB
on error.
Returns .true.
if given statement has been prepared.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
Steps rows. Returns E_DB_STEP
on error.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
Returns SQLite 3 library version as allocatable string.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
logical, | intent(in), | optional | :: | name |
Add prefix `libsqlite/'. |
Version string.
Returns byte size of column value of given index.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(in) | :: | index |
Column index. |
||
integer, | intent(out) | :: | value |
Value. |
Finalises given database statement. Sets error
to E_NULL
if
statement is not associated and to E_DB_FINALIZE
if finalisation
failed.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(db_stmt_type), | intent(inout) | :: | db_stmt |
Database statement type. |
||
integer, | intent(out), | optional | :: | error |
Error code. |
Sends log message to SQLite error log handler. The callback has to
be set through dm_db_set_log_callback()
initially.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | err_code |
Error code. |
||
character(len=*), | intent(in) | :: | err_msg |
Error message. |
Delays execution for given duration in msec.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | msec |
Time in [msec]. |