Argument | Description | Types / Required |
db | The database ID returned by Sqlite.open. | number
required |
The
Sqlite.close action closes a
SQLite database previously opened by
Sqlite.open. Only files
opened using
path are closed, so if the database was opened using
name, it is not actually closed, as data source and paradata resources may still be in use by other parts of CSPro.
Further information about closing databases is available on the SQLite website:
sqlite3_close.
The action returns undefined.
The action throws an exception if any of its arguments are not specified in a valid form, or if:
- The database ID is not valid.
- The database cannot be closed.
// example data available at: https://www.csprousers.org/resources/help/census2020.db
// open the SQLite database: census2020.db
numeric dbCensus2020 = tonumber(CS.Sqlite.open(path := "census2020.db"));
// quit if there was an error opening the database
if dbCensus2020 = default then
exit;
endif;
// query the database...
// string scalar: result is California
string largestState =
CS.Sqlite.exec(db := dbCensus2020,
sql := "SELECT `name` FROM `census2020` ORDER BY `resident_pop` DESC LIMIT 1;");
// numeric scalar: result is 15920696
numeric populationStatesBeginningWithA = tonumber(
CS.Sqlite.exec(db := dbCensus2020,
sql := "SELECT SUM(`resident_pop`) FROM `census2020` WHERE `name` LIKE 'A%';"));
// scalar array: result is California, District of Columbia, Georgia, Pennsylvania, Virginia, West Virginia
List string statesEndingInIa;
statesEndingInIa.updateValueFromJson(
CS.Sqlite.exec(db := dbCensus2020,
sql := "SELECT `name` FROM `census2020` WHERE `name` LIKE '%ia' ORDER BY `name`;",
rowFormat := "scalarArray"));
// close the database
CS.Sqlite.close(db := dbCensus2020);