sqlite-to-fast-sql
Skill75 starsChanged 32 days agoMITView on GitHub
Migrates SQLite and SQL-style Capacitor storage (@capacitor-community/sqlite, cordova-sqlite-storage, @ionic/storage with a SQLite driver, TypeORM/Drizzle/Kysely capacitor drivers, and other bridge-based SQL plugins) to @capgo/capacitor-fast-sql. Use when replacing createConnection/open/query/run/executeSet calls, slow large result sets over the Capacitor bridge, adding SQLCipher encryption, keeping transactions and BLOBs, moving key-value data to KeyValueStore, preserving existing database files during the switch, or fixing Fast SQL setup errors (ATS NSAllowsLocalNetworking, Android cleartext localhost, "Encryption is not available in this build", web OPFS COOP/COEP headers). Do not use for non-SQL storage such as Preferences (capacitor-offline-first), Ionic Secure Storage or Identity Vault (ionic-enterprise-sdk-migration), generic app upgrades (capacitor-app-upgrades), or code that already wraps Fast SQL.
- Installs packages
1 other project uses a version of this, 1 of them edited.
Adopted by
Most recently taken up by
- Aver005/agent-skillsedited, first seen Feb 14, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 1
- Aver005/agent-skills★ 217% same
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository56 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- capacitor-accessibilitySkill
- capacitor-app-intentsSkill
- capacitor-apple-review-preflightSkill
- capacitor-app-storeSkill
- capacitor-app-upgradesSkill
- capacitor-app-upgrade-v4-to-v5Skill
- capacitor-app-upgrade-v5-to-v6Skill
- capacitor-app-upgrade-v6-to-v7Skill
- capacitor-app-upgrade-v7-to-v8Skill
- capacitor-app-upgrade-v8-to-v9Skill
- capacitor-best-practicesSkill
- capacitor-ci-cdSkill
- capacitor-deep-linkingSkill
- capacitor-ios-resizabilitySkill
- capacitor-ios-security-hardeningSkill
- capacitor-keyboardSkill
- capacitor-mcpSkill
- capacitor-offline-firstSkill
- capacitor-performanceSkill
- capacitor-plugin-spm-supportSkill
- capacitor-pluginsSkill
- capacitor-plugin-upgradesSkill
- capacitor-plugin-upgrade-v4-to-v5Skill
- capacitor-plugin-upgrade-v5-to-v6Skill
- capacitor-plugin-upgrade-v6-to-v7Skill
- capacitor-plugin-upgrade-v7-to-v8Skill
- capacitor-plugin-upgrade-v8-to-v9Skill
- capacitor-push-notificationsSkill
- capacitor-securitySkill
- capacitor-splash-screenSkill
- capacitor-testingSkill
- capacitor-uiscene-migrationSkill
- capawesome-live-update-migrationSkill
- capgo-cli-usageSkill
- capgo-cloudSkill
- capgo-live-updatesSkill
- capgo-native-buildsSkill
- capgo-organization-managementSkill
- capgo-release-managementSkill
- capgo-release-workflowsSkill
- cocoapods-to-spmSkill
- cordova-to-capacitorSkill
- debugging-capacitorSkill
- framework-to-capacitorSkill
- ionic-appflow-migrationSkill
- ionic-designSkill
- ionic-enterprise-sdk-migrationSkill
- ios-android-logsSkill
- konsta-uiSkill
- safe-area-handlingSkill
- skill-creatorSkill
- subscription-app-revenueSkill
- tailwind-capacitorSkill
- webapp-to-capacitorSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Do not use for:
- Very specific: line 103
If the app already has a network security config, merge the domain-config instead of replacing the file.
- Very specific: line 108
Keep the key out of JS source: store it with @capgo/capacitor-native-biometric or fetch it from your backend.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
SQLite to Fast SQL Migration
Swap a bridge-based SQL plugin for @capgo/capacitor-fast-sql without losing user data.
When to Use
TRIGGER when:
package.jsonhas@capacitor-community/sqlite,cordova-sqlite-storage,@capawesome-team/capacitor-sqlite, an ORM capacitor driver, or another SQLite plugin, and the user wants Fast SQL.- Large
SELECTs or sync writes are slow because every row crosses the Capacitor bridge as JSON. - The app needs encryption, transactions, batch writes, BLOBs, or an encrypted key-value store.
Do not use for:
@capacitor/preferencesor IndexedDB-only apps ->capacitor-offline-first.@ionic-enterprise/secure-storage/ Identity Vault ->ionic-enterprise-sdk-migration.- Apps already on Fast SQL needing schema design or sync logic ->
capacitor-offline-first.
Live Project Snapshot
Detected SQL-related packages:
!node -e "const fs=require('fs');if(!fs.existsSync('package.json'))process.exit(0);const pkg=JSON.parse(fs.readFileSync('package.json','utf8'));const needles=['sqlite','sqlcipher','typeorm','watermelondb','pouchdb','@capacitor-community/sqlite','@capawesome-team/capacitor-sqlite','@capgo/capacitor-fast-sql'];const out=[];for(const section of ['dependencies','devDependencies']){for(const [name,version] of Object.entries(pkg[section]||{})){if(needles.some((needle)=>name.includes(needle)))out.push(section+'.'+name+'='+version)}}console.log(out.sort().join('\n'))"
How Fast SQL Differs
- Native SQLite is reached through a token-protected HTTP server on
localhost, not the Capacitor bridge, so big result sets and batches avoid bridge serialization. This is why iOS ATS and Android cleartext config are required. - Plugin major follows Capacitor major (v8 for Capacitor 8). Current: 8.2.x.
- Database files: iOS
Documents/<database>.db, Android<filesDir>/<database>.db. Other plugins use different paths and names, so existing data is not picked up automatically. - Web: official
@sqlite.org/sqlite-wasmwith OPFS persistence (bundled dependency, nosql.jsinstall). Older versions used sql.js + IndexedDB; that data is not migrated automatically. - Encryption: SQLCipher, opt-in per platform.
Procedure
Step 1: Inventory
Read package.json and grep the data layer. Record: plugin and version, database names, schema/migration mechanism (user_version, upgrade statements, ORM migrations), use of transactions, BLOBs, encryption (and where the key comes from), JSON import/export, web support, and approximate data size. Report this before changing code.
Step 2: Map the API
import { FastSQL, KeyValueStore } from '@capgo/capacitor-fast-sql';
const db = await FastSQL.connect({ database: 'app' }); // { encrypted, encryptionKey, readOnly }
const rows = await db.query('SELECT * FROM todo WHERE done = ?', [0]);
const { rowsAffected, insertId } = await db.run('INSERT INTO todo (title) VALUES (?)', ['A']);
await db.execute('CREATE TABLE IF NOT EXISTS todo (id INTEGER PRIMARY KEY, title TEXT, done INTEGER DEFAULT 0)');
await db.executeBatch([{ statement: 'INSERT INTO log (m) VALUES (?)', params: ['x'] }]);
await db.transaction(async (tx) => { await tx.run('UPDATE a SET n = n - 1'); await tx.run('UPDATE b SET n = n + 1'); });
await FastSQL.disconnect('app');@capacitor-community/sqlite | Fast SQL |
new SQLiteConnection(CapacitorSQLite), createConnection(name, encrypted, mode, version, readonly), db.open() | FastSQL.connect({ database, encrypted, encryptionKey, readOnly }) |
db.query(sql, values) -> { values } | db.query(sql, params) -> rows array |
db.run(sql, values) -> { changes: { changes, lastId } } | db.run(sql, params) -> { rowsAffected, insertId } |
db.execute(multiStatementSql) | db.execute(sql) per statement, or executeBatch |
db.executeSet([{ statement, values }]) | db.executeBatch([{ statement, params }]) |
beginTransaction/commitTransaction/rollbackTransaction, transaction flag on calls | db.transaction(cb) or beginTransaction() / commit() / rollback() |
addUpgradeStatement + version | Keep your own PRAGMA user_version migration runner |
closeConnection(name) | FastSQL.disconnect(name) |
importFromJson / exportToJson | Not provided; write rows with executeBatch |
cordova-sqlite-storage db.executeSql(sql, params, ok, err) / db.transaction(tx => tx.executeSql(...)) | db.query/db.run and db.transaction(async tx => ...) |
Key-value data (Ionic Storage, Preferences-like wrappers) -> KeyValueStore.open({ database, encrypted, encryptionKey, store }) with set/get/has/remove/clear/keys.
Step 3: Install and configure
npm install @capgo/capacitor-fast-sql
npx cap synciOS ios/App/App/Info.plist (loopback only; does not weaken ATS for other hosts):
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsLocalNetworking</key>
<true/>
</dict>Android android/app/src/main/res/xml/network_security_config.xml, referenced by android:networkSecurityConfig="@xml/network_security_config" on <application>:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="false">localhost</domain>
<domain includeSubdomains="false">127.0.0.1</domain>
</domain-config>
</network-security-config>If the app already has a network security config, merge the domain-config instead of replacing the file.
Encryption (only if encrypted: true):
- Android:
implementation 'net.zetetic:sqlcipher-android:4.13.0'(or current) inandroid/app/build.gradledependencies. - iOS (CocoaPods):
pod 'CapgoCapacitorFastSql/SQLCipher', :path => '../../node_modules/@capgo/capacitor-fast-sql'inios/App/Podfile, thenpod install. For SPM projects check the plugin README for the current SQLCipher option. - Keep the key out of JS source: store it with
@capgo/capacitor-native-biometricor fetch it from your backend.
Web (only if the app ships on web): serve Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp, and in Vite add optimizeDeps.exclude: ['@sqlite.org/sqlite-wasm']. CapgoCapacitorFastSql.configureWeb({ ... }) before the first connect() is optional and a no-op on native.
Step 4: Preserve existing data
Pick one with the user:
- Dual-plugin release (safest): keep the old plugin installed for one release. On first launch, if a
migratedflag is missing, read tables from the old plugin,executeBatchthem into Fast SQL inside a transaction, verify counts, set the flag. Remove the old plugin in the next release. - File copy: copy the old
.dbfile to Fast SQL's path before the firstconnect()(old community plugin files are typically named<name>SQLite.db; verify the real path on a device first). Encrypted files keep working only with the same key and a compatible SQLCipher version. - Re-sync from server: acceptable when local data is a cache; confirm with the user.
Step 5: Swap code and remove the old plugin
Replace imports and calls behind the existing data-access layer; keep schema and migration steps. Then (after the carry-over release if option 1):
npm uninstall @capacitor-community/sqlite # or the plugin in use
npx cap syncVerification
rg -n "@capacitor-community/sqlite|cordova-sqlite|CapacitorSQLite|SQLiteConnection" -g '!node_modules' srcreturns nothing after cleanup.- Upgrade test: install the current store build, create data, install the new build over it; row counts match.
- Smoke test on both platforms: create, read, update, delete, transaction rollback (throw inside
transactionand confirm no partial writes), BLOB round-trip (Uint8Array). - Encrypted DB: opening with a wrong key fails; file is unreadable with plain
sqlite3. - Measure a large query before/after to confirm the performance goal.
Error Handling
| Error / symptom | Fix |
iOS: requests to http://localhost:<port> fail, The resource could not be loaded because the App Transport Security policy requires the use of a secure connection | Add NSAllowsLocalNetworking |
Android: net::ERR_CLEARTEXT_NOT_PERMITTED or CLEARTEXT communication to localhost not permitted by network security policy | Add the localhost network_security_config.xml and reference it in the manifest |
iOS: Encryption is not available in this build. Add SQLCipher to enable encryption. | Install the SQLCipher subspec or use encrypted: false |
Android: Encryption is not available. ... to your app's build.gradle to enable encryption. | Add net.zetetic:sqlcipher-android to the app module |
Encryption key is required when encrypted is true | Pass encryptionKey with encrypted: true |
| App starts with an empty database after update | New file path; run the Step 4 carry-over |
Web: OPFS / SharedArrayBuffer errors | Missing COOP/COEP headers or Vite pre-bundling sqlite-wasm |
query returns objects where code expected { values } | Old community-plugin result shape; update callers to use the rows array |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

