SQLite
Installation
for SQLite:
npm install sqlite3for Better SQLite:
npm install better-sqlite3for sql.js:
npm install sql.jsfor Capacitor, Cordova, Expo, NativeScript and React Native, check the supported platforms.
Data Source Options
See Data Source Options for the common data source options.
sqlite data source options
sqlite data source optionsdatabase- Database path. For example, "mydb.sql"
better-sqlite3 data source options
better-sqlite3 data source optionsdatabase- Database path. For example, "mydb.sql"statementCacheSize- Cache size of the SQLite statement to speed up queries (default 100).prepareDatabase- Function to run before a database is used in typeorm. You can access the original better-sqlite3 Database object here.nativeBinding- Relative or absolute path to the native addon (better_sqlite3.node).
sql.js data source options
sql.js data source optionsdatabase: The raw UInt8Array database that should be imported.sqlJsConfig: Optional initialize config for sql.js.autoSave: Enable automatic persistence of database changes, requires eitherlocationorautoSaveCallback. When set totrue, every change is saved to the file system (Node.js) or tolocalStorage/indexedDB(browser) iflocationis specified, or theautoSaveCallbackis invoked otherwise.autoSaveCallback: A function that gets called when changes to the database are made andautoSaveis enabled. The function gets aUInt8Arraythat represents the database.location: The file location to load and save the database to.useLocalForage: Enables the usage of the localforage library to save and load the database asynchronously from the indexedDB instead of using the synchrony local storage methods in a browser environment. The localforage node module needs to be added to your project, and the localforage.js should be imported in your page.
capacitor data source options
capacitor data source optionsdatabase- Database name (capacitor-sqlite will add the suffixSQLite.db)driver- The capacitor-sqlite instance. For example,new SQLiteConnection(CapacitorSQLite).mode- Set the mode for database encryption: "no-encryption" | "encryption" | "secret" | "newsecret"version- Database versionjournalMode- The SQLite journal mode (optional)
cordova data source options
cordova data source optionsdatabase- Database namelocation- Where to save the database. See cordova-sqlite-storage for options.
expo data source options
expo data source optionsdatabase- Name of the database. For example, "mydb".driver- The Expo SQLite module. For example,require('expo-sqlite').
nativescript data source options
nativescript data source optionsdatabase- Database name
react-native data source options
react-native data source optionsdatabase- Database namelocation- Where to save the database. See react-native-sqlite-storage for options.
Column Types
int, int2, int8, integer, tinyint, smallint, mediumint, bigint, decimal, numeric, float, double, real, double precision, datetime, varying character, character, native character, varchar, nchar, nvarchar2, unsigned big int, boolean, blob, text, clob, date
Last updated
Was this helpful?