Registry / database / tauri-sql-tab

tauri-sql-tab

JSON →
library1.0.1jsnpmunverified

High-level SQL query interface for Tauri desktop applications, wrapping @tauri-apps/plugin-sql with an Active Record pattern. Current version 1.0.1, weekly release cadence. Key differentiators: zero Rust logic (all DB operations in JS/TS), fluent query builder with polymorphic joins, automatic schema synchronization from tabla-model definitions, and cross-compatibility with sqlite3-tab and mysql-tab. Supports SQLite, MySQL, and PostgreSQL via Tauri plugin. Part of the dbtabla ecosystem.

npm install tauri-sql-tab
INSTALL
IMPORT
SIG · TAURI-SQL-TAB
T
tauri-sql-tab
databasejavascriptv1.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tauriSqlTab
import { tauriSqlTab } from 'tauri-sql-tab'
import tauriSqlTab from 'tauri-sql-tab'; const { tauriSqlTab } = require('tauri-sql-tab')
Default export is not available; must use named import. CJS require works but is not recommended for new code.
Database
import Database from '@tauri-apps/plugin-sql'
const { Database } = require('@tauri-apps/plugin-sql'); import { Database } from '@tauri-apps/plugin-sql'
@tauri-apps/plugin-sql has a default export; named export is incorrect. Use import Database from '...'.
Model
import Model from 'tabla-model'
const Model = require('tabla-model'); import { Model } from 'tabla-model'
tabla-model also uses default export; named export Model is not available.

Shows the full setup: load a SQLite database via Tauri plugin, wrap with tauriSqlTab, define a model, register, insert, and select rows.

import Database from '@tauri-apps/plugin-sql'; import { tauriSqlTab } from 'tauri-sql-tab'; import Model from 'tabla-model'; async function main() { const dbTauri = await Database.load('sqlite:test.db'); const db = new tauriSqlTab(dbTauri); const User = new Model('users', { colums: [ { name: 'id', type: 'integer', primary: true, autoincrement: true }, { name: 'name', type: 'varchar(100)' }, { name: 'email', type: 'varchar(100)', unique: true } ] }); db.addModel(User); await db.tabla('users').insert({ name: 'Alice', email: 'alice@example.com' }); const users = await db.tabla('users').select('id > 0'); console.log(users); } main().catch(console.error);
Debug
Known issues
breakingDatabase.load() must be called before creating tauriSqlTab instance. Calling methods without a loaded database throws error.
fix
Use await for Database.load() and pass the resulting db handle to new tauriSqlTab(dbHandle).
affects: >=1.0.0
gotchaModel columns property is named 'colums' (misspelled), not 'columns'. Using 'columns' will silently fail to define columns.
fix
Use 'colums' (without 'n') in model construction: new Model('users', { colums: [...] }).
affects: >=1.0.0
deprecatedSupport for Tauri v1 is deprecated in the current implementation. Future versions may require Tauri v2.
fix
Upgrade to Tauri v2 and configure permissions in capabilities/default.json.
affects: >=1.0.0
gotchaIf using MySQL or PostgreSQL, the database URL must include the driver prefix (mysql:, postgres:) in Database.load().
fix
Use 'postgres://user:pass@host/db' or 'mysql://user:pass@host/db' as the argument to Database.load().
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: db.tabla is not a function
The database handle passed to tauriSqlTab was not properly loaded (Database.load() failed or was not awaited).
fix
Ensure Database.load() is awaited and the returned handle is passed to new tauriSqlTab(handle).
Error: plugin 'sql' not found
Tauri's SQL plugin is not registered in the Rust backend (src-tauri/src/lib.rs).
fix
Add `.plugin(tauri_plugin_sql::Builder::default().build())` to the Tauri builder in Rust code.
Error: Permission denied: sql:allow-select
Tauri v2 requires explicit permissions for SQL operations; the default config does not include them.
fix
Add 'sql:allow-load', 'sql:allow-execute', 'sql:allow-select' to permissions in src-tauri/capabilities/default.json.
Upgrade
Version history
1.0.1latest on npm
Audit
Dependencies
@tauri-apps/plugin-sqlrequiredRequired to load and interact with SQL databases in Tauri (runtime peer dep).
tabla-modeloptionalUsed to define and register model schemas for Active Record operations.
dbtablarequiredCore library providing the base DbTabla class and query builder functionality.
Agent activity
20 hits · last 30 days
node
18
Meta
1
OpenAI (training)
1
Resources
tauri-sql-tab — npm install tauri-sql-tab · libregistry