ArkData FAQs
How do I view detailed SQL execution error logs of an RDB store?
Call on('sqliteErrorOccurred') to obtain the error logs that occur during SQL execution.
How do I view SQL statements generated by an RDB store?
Call relationalStore.getInsertSqlInfo to obtain the SQL statement used to insert data.
Call relationalStore.getUpdateSqlInfo to obtain the SQL statement used to update data.
Call relationalStore.getDeleteSqlInfo to obtain the SQL statement used to delete data.
Call relationalStore.getQuerySqlInfo to obtain the SQL statement used to query data.
Different Files in an RDB Store
When an RDB store is used, different file artifacts may be generated. The purpose of each file is described in the following table.
| File Type | Description |
|---|---|
| .db | Database persistent file, used to store database data. |
| .db-wal | Used to save operation logs, allowing changes to be rolled back upon transaction failure to ensure data consistency. This file exists only when the database uses WAL mode (the system default logging mode is WAL (Write Ahead Log) mode). |
| .db-shm | Shared memory file, used to coordinate changes to the same db file by multiple database connections to prevent data conflicts. This file exists only when the database uses WAL mode (the system default logging mode is WAL (Write Ahead Log) mode). |
| .key_lock | Used to save file lock information. |
| .pub_key | Used to save database key information. This file exists only when database encryption is configured and custom encryption parameters are not configured (that is, when encrypt is set to true via StoreConfig and cryptoParam is not configured). |
| .db-dwr | Used to save file header information. |
| .db-compare | Used to save all DDL statements. |
How to Configure the encryptionKey Parameter When Calling getRdbStore to Open an Encrypted Relational Database with a Raw Key?
In an RDB store, when you call getRdbStore to open an encrypted database with a raw key, configure the CryptoParam.encryptionKey parameter as follows:
import { relationalStore } from '@kit.ArkData'
let password: string = "x'3605d7de19311edba4d3c88143c61cdd79dd5a58bc829c8b1234567891234567'"; // Replace with the actual database password.
let key = new Uint8Array(buffer.from(password, 'utf8').buffer); // Returns a Uint8Array.
// Configure encryption parameters.
const cryptoParam: relationalStore.CryptoParam = {
encryptionKey: key, // Mandatory. Specifies the key.
};