db_exporter library

WAL-safe export of SQLite-backed Flutter databases.

Point a DbSource at any SQLite connection — Drift, sqflite or raw sqlite3 — pick a format, pick a destination:

final exporter = DbExporter(
  DbSource(databasePath: db.path, query: db.rawQuery),
);

await exporter.exportDatabaseFile(
  destination: const ExportDestination.share(subject: 'Backup'),
);

Classes

AppDirectoryDestination
See ExportDestination.appDirectory.
CsvExporter
One .csv per table.
CsvWriter
Minimal RFC 4180 CSV encoder.
DbExporter
Exports a SQLite-backed database to a file and delivers it somewhere.
DbSource
A SQLite-backed database to read from.
DeviceFolderDestination
See ExportDestination.deviceFolder.
DirectoryDestination
See ExportDestination.directory.
ExcelExporter
A single .xlsx workbook, one sheet per table.
ExportDestination
Where a finished export should end up.
ExportedFile
A single file produced by an export.
ExportResult
The outcome of an export.
JsonExporter
A single JSON document keyed by table name.
RawDatabaseExporter
Exports the SQLite file itself — the only format that round-trips back into Drift or sqflite unchanged.
SaveAsDestination
See ExportDestination.saveAs.
ShareDestination
See ExportDestination.share.
TableData
One table's rows, already materialised in memory.
TabularExporter
Writes already-read tables into a concrete file format.
ValueCodec
Converts raw SQLite values into the representation each format expects.

Enums

ExportFormat
The on-disk shape an export is written in.
RawCopyStrategy
How to obtain a consistent copy of a live SQLite file.

Typedefs

ExportProgress = void Function(int completed, int total, String? table)
Progress callback, emitted once per table plus once when writing finishes.
RawExecute = Future<void> Function(String sql)
Runs a statement that returns no rows (VACUUM, PRAGMA writes).
RawQuery = Future<List<Map<String, Object?>>> Function(String sql)
Runs a SQL statement and returns the resulting rows as plain maps.

Exceptions / Errors

DbExportException
Thrown when an export cannot be completed.