|
1 | 1 | # LiveCode SQLite library |
2 | 2 |
|
3 | | -A LiveCode SQLite library borrowed from revIgniter. |
| 3 | +This SQLite library is borrowed from revIgniter's database library |
| 4 | +and includes all features as described in the revIgniter User Guide |
| 5 | +(see chapter [Database Library](https://revigniter.com/userGuide/database/index.html)). |
| 6 | +It is meant to be used with desktop and mobile apps. |
| 7 | + |
| 8 | +### Requirements |
| 9 | + |
| 10 | +LiveCode version 9 or higher |
| 11 | + |
| 12 | +### How to use this library: |
| 13 | + |
| 14 | +Place the library in the message path, then call the rigLoadDatabase |
| 15 | +function to connect to your database like: |
| 16 | + |
| 17 | + get rigLoadDatabase(tParams, tReturn, tActiveGroup, tOptions) |
| 18 | + |
| 19 | +- **tParams** can optionally be a path |
| 20 | + to a database or an array of database settings like the settings |
| 21 | + in revIgniter's database.lc. |
| 22 | +- **tReturn** is an optional boolean which determines if the |
| 23 | + database ID should be returned. |
| 24 | +- **tActiveGroup** is optional and is used to give the database |
| 25 | + configuration group a name. |
| 26 | +- **tOptions** the optional fourth parameter is a comma delimited |
| 27 | + list of SQLite options. It can be empty or can contain "binary", |
| 28 | + "extensions" or both. Note: This parameter is needless if all |
| 29 | + settings are included in the first parameter. |
| 30 | + |
| 31 | +Alternatively you can connect to an in-memory database or to a |
| 32 | +new database. Build an initial table using the rigNewTableStructure() |
| 33 | +function and connect using the rigConnectDB handler like: |
| 34 | + |
| 35 | + put "INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT" into tInitTableA["recipe"][1]["ID"] |
| 36 | + put "varchar(255,0) DEFAULT NULL" into tInitTableA["recipe"][2]["Name"] |
| 37 | + put "TEXT" into tInitTableA["recipe"][3]["Directions"] |
| 38 | + |
| 39 | + put rigNewTableStructure(tInitTableA) into tInitTable |
| 40 | + |
| 41 | + rigConnectDB tDBfilePath, tInitTable tReturn tActiveGroup tOptions |
| 42 | + |
| 43 | +- **tDBfilePath** the value of this optional parameter can be |
| 44 | + empty or a file path or "memory" or "mem" or "in-memory" or |
| 45 | + "in-mem" or "inmemory" or "inmem" for creating an in-memory |
| 46 | + database. If it is empty the user is prompted to choose the |
| 47 | + folder where the database is located. To create a new database |
| 48 | + the dialog needs to be canceled. |
| 49 | +- **tInitTable** is optional and includes the array data to build |
| 50 | + the initial table. |
| 51 | +- **tReturn** is a boolean which determines if the database ID should |
| 52 | + be returned. |
| 53 | +- **tActiveGroup** is optional and is used to give the database |
| 54 | + configuration group a name. |
| 55 | +- **tOptions** is a comma delimited list of SQLite options. It can |
| 56 | + be empty or can contain "binary", "extensions" or both. |
| 57 | + |
| 58 | +### How to convert a query result array to a datagrid array: |
| 59 | + |
| 60 | +This library provides a handler which converts database query result arrays |
| 61 | +to datagrid arrays. |
| 62 | + |
| 63 | + queryResultArrayToDgArray @pArray pFields |
| 64 | + |
| 65 | +- **pArray** is the database query result index named "resultarray" |
| 66 | +- **pFields** is the database query result index "fieldnames" which |
| 67 | + contains the table field names in a numbered array |
| 68 | + |
| 69 | +Here is an example: |
| 70 | + |
| 71 | + # ALL QUERY DATA |
| 72 | + put rigDbGet("recipe") into tQuery |
| 73 | + |
| 74 | + # THE QUERY RESULT ARRAY |
| 75 | + put tQuery["resultarray"] into tDataGridArray |
| 76 | + |
| 77 | + # CONVERT RESULT ARRAY TO DATGRID ARRAY |
| 78 | + queryResultArrayToDgArray tDataGridArray, tQuery["fieldnames"] |
| 79 | + |
| 80 | + # POPULATE DATAGRID |
| 81 | + set the dgData of grp "myDatagrid" to tDataGridArray |
| 82 | + |
| 83 | +### License |
| 84 | + |
| 85 | +For the license terms see the LICENSE file. |
| 86 | + |
| 87 | +### Meta |
| 88 | + |
| 89 | +Version: 1.0.0 |
| 90 | +Web Site: <https://revigniter.com/> |
| 91 | + |
| 92 | +Author: Ralf Bitter |
0 commit comments