xray_sqflite_inspector 0.2.1
xray_sqflite_inspector: ^0.2.1 copied to clipboard
Database inspector for sqflite and sqflite_common_ffi databases in xRay. Pure Dart — works with Flutter and Dart backends.
xray_sqflite_inspector #
Browse, query and edit a sqflite database in the Database tab of the xRay inspector. Works with sqflite and sqflite_common_ffi.
For full documentation and guides, see the xRay docs.
Disclaimer: This is a commercial package. To use this package, you need to have either a commercial xRay license or a free xRay Community License. The xRay desktop apps for macOS, Windows and Linux are the authorized UI clients for this library. For more details, please check the LICENSE file.
Setup #
Pass the database your app already opened:
final db = await openDatabase('app.db');
XRayInspectorServerConfig(inspectors: [
XRaySqfliteInspector(database: db),
]);
The Database tab lists the tables and views with their row counts, pages through rows, and runs SQL in its Query view. It is titled with the database's file name; pass title: to name it yourself, and id: when two databases share a title.
Allowing edits #
Browsing and read-only queries (SELECT, WITH … SELECT, EXPLAIN) are all the inspector allows by default. Turn on adding, editing and deleting rows, and queries that change data, with allowWrites:
XRaySqfliteInspector(database: db, allowWrites: true)
A row is addressed by its primary key, or by rowid in a table without one. Views, and WITHOUT ROWID tables without a primary key, stay read-only.
One connection, the app's own #
xRay never opens the database file a second time. Its statements run on the Database you pass, so they queue with the app's own and wait while the app holds a transaction instead of conflicting with it.
sqflite has no change notifications: an app that keeps rows in memory sees xRay's edits on its next read.
Encrypted databases #
SQLCipher through sqflite_sqlcipher works as is: its Database is the same type, so pass the one openDatabase(path, password: …) returns. xRay reads through that unlocked connection and never needs the key.