Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(import): restore Navicat .nb3 backups from the import dialog

Alan Saputra Lengkoan56f787ebc1a5
diff --git a/apps/desktop/src/components/import/TableImportDialog.vue b/apps/desktop/src/components/import/TableImportDialog.vue
index e2df38743c..d7330cd966 100644
--- a/apps/desktop/src/components/import/TableImportDialog.vue
+++ b/apps/desktop/src/components/import/TableImportDialog.vue
@@ -9,7 +9,7 @@ import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { SearchableSelect } from "@/components/ui/searchable-select";
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
-import { AlertTriangle, ArrowLeft, ArrowRight, Check, CheckCircle2, FileCode, FileJson, FileSpreadsheet, FileText, FileUp, Loader2, Maximize2, Minimize2, Plus, RefreshCw, Square, Trash2, Upload, X } from "@lucide/vue";
+import { AlertTriangle, ArrowLeft, ArrowRight, Check, CheckCircle2, DatabaseBackup, FileCode, FileJson, FileSpreadsheet, FileText, FileUp, Loader2, Maximize2, Minimize2, Plus, RefreshCw, Square, Trash2, Upload, X } from "@lucide/vue";
import { useConnectionStore } from "@/stores/connectionStore";
import { ensureReadOnlyWriteAccess } from "@/lib/database/readOnlyWriteAccess";
import { useSettingsStore } from "@/stores/settingsStore";
@@ -78,6 +78,7 @@ const props = defineProps<{
type ImportTargetMode = "existing" | "create";
type ImportSource = string | File;
+type SourceFormatCard = { value: api.TableImportSourceFormat | typeof NAVICAT_BACKUP_FORMAT; icon: any; labelKey: string; descriptionKey: string };
export interface GeneratedColumnItem {
id: string;
@@ -104,6 +105,9 @@ interface BatchImportTask {
}
const SKIP_VALUE = "__skip__";
+const NAVICAT_BACKUP_FORMAT = "nb3";
+const NAVICAT_BACKUP_FILTER = { name: "Navicat backup", extensions: [NAVICAT_BACKUP_FORMAT] };
+const NAVICAT_BACKUP_DATABASE_TYPES = new Set<DatabaseType>(["mysql", "postgres"]);
const TARGET_COLUMNS_TIMEOUT_MS = 15000;
const TARGET_COLUMNS_TIMEOUT = Symbol("target-columns-timeout");
@@ -152,6 +156,7 @@ const progress = ref<api.TableImportProgress | null>(null);
const errorMessage = ref("");
const wizardStep = ref<TableImportWizardStep>("source");
const fileInput = ref<HTMLInputElement | null>(null);
+const navicatBackupInput = ref<HTMLInputElement | null>(null);
const delimiter = ref(",");
const decimalSeparator = ref<"." | ",">(".");
const textEncoding = ref<api.TableImportTextEncoding>("auto");
@@ -198,7 +203,11 @@ const selectedConnection = computed(() => (props.prefillConnectionId ? store.get
const structureDatabaseType = computed(() => tableStructureDatabaseTypeForConnection(selectedConnection.value));
const supportsDuckDbParquetImport = computed(() => structureDatabaseType.value === "duckdb");
const availableFormatOptions = computed(() => formatOptions.filter((format) => format.value !== "parquet" || supportsDuckDbParquetImport.value));
-const importFileExtensions = computed(() => ["csv", "tsv", "txt", "json", "xlsx", "xlsm", "xls", "sql", ...(supportsDuckDbParquetImport.value ? ["parquet"] : [])]);
+// A Navicat `.nb3` archive restores a whole database, so it is only offered from the
+// database-level entry of the connection types the archive reader supports.
+const supportsNavicatBackupImport = computed(() => !props.prefillTable && !!selectedConnection.value && NAVICAT_BACKUP_DATABASE_TYPES.has(selectedConnection.value.db_type));
+const sourceFormatCards = computed<SourceFormatCard[]>(() => [...availableFormatOptions.value, ...(supportsNavicatBackupImport.value ? [{ value: NAVICAT_BACKUP_FORMAT, icon: DatabaseBackup, labelKey: "tableImport.formatNb3", descriptionKey: "tableImport.formatNb3Description" } as const] : [])]);
+const importFileExtensions = computed(() => ["csv", "tsv", "txt", "json", "xlsx", "xlsm", "xls", "sql", ...(supportsDuckDbParquetImport.value ? ["parquet"] : []), ...(supportsNavicatBackupImport.value ? [NAVICAT_BACKUP_FORMAT] : [])]);
// Mirrors the conflict SQL dispatch in transfer.rs. Other dialects must keep
// ordinary INSERT/error behavior instead of approximating an upsert.
const IMPORT_CONFLICT_DATABASE_TYPES = new Set<DatabaseType>(["postgres", "kingbase", "opengauss", "sqlite", "cloudflare-d1", "duckdb", "mysql", "doris", "starrocks"]);
@@ -1017,12 +1026,11 @@ async function selectFile() {
{ name: "Excel", extensions: ["xlsx", "xlsm", "xls"] },
{ name: "SQL", extensions: ["sql"] },
...(supportsDuckDbParquetImport.value ? [{ name: "Parquet", extensions: ["parquet"] }] : []),
+ ...(supportsNavicatBackupImport.value ? [NAVICAT_BACKUP_FILTER] : []),
],
});
if (!selected) return;
- const sources = Array.isArray(selected) ? selected : [selected];
- if (targetMode.value === "create") await prepareBatchSources(sources);
- else assignSelectedSource(sources[0]);
+ await applySelectedSources(Array.isArray(selected) ? selected : [selected]);
}
async function handleFileInputChange(event: Event) {
@@ -1030,8 +1038,65 @@ async function handleFileInputChange(event: Event) {
const files = Array.from(input.files || []);
input.value = "";
if (!files.length || running.value) return;
- if (targetMode.value === "create") await prepareBatchSources(files);
- else assignSelectedSource(files[0]);
+ await applySelectedSources(files);
+}
+
+async function applySelectedSources(sources: ImportSource[]) {
+ // A Navicat archive restores a whole database, so only a single-file selection may
+ // take that path; a mixed batch must stay in the table-import flow for the other files.
+ const navicatBackup = supportsNavicatBackupImport.value && sources.length === 1 ? sources.find((source) => sourceName(source).toLowerCase().endsWith(`.${NAVICAT_BACKUP_FORMAT}`)) : undefined;
+ if (navicatBackup) await openNavicatBackupRestore(navicatBackup);
+ else if (targetMode.value === "create") await prepareBatchSources(sources);
+ else assignSelectedSource(sources[0]!);
+}
+
+function selectFormatCard(format: SourceFormatCard["value"]) {
+ if (format === NAVICAT_BACKUP_FORMAT) void selectNavicatBackupFile();
+ else sourceFormat.value = format;
+}
+
+async function selectNavicatBackupFile() {
+ if (!isTauriRuntime()) {
+ navicatBackupInput.value?.click();
+ return;
+ }
+ const { open } = await import("@tauri-apps/plugin-dialog");
+ const selected = await open({ multiple: false, filters: [NAVICAT_BACKUP_FILTER] });
+ if (typeof selected === "string") await openNavicatBackupRestore(selected);
+}
+
+async function handleNavicatBackupInputChange(event: Event) {
+ const input = event.target as HTMLInputElement;
+ const file = input.files?.[0];
+ input.value = "";
+ if (file && !running.value) await openNavicatBackupRestore(file);
+}
+
+/**
+ * Navicat archives hold whole databases (DDL, rows, routines, triggers), so they are
+ * restored by the SQL file executor, prefilled with this dialog's target database.
+ */
+async function openNavicatBackupRestore(source: ImportSource) {
+ const connectionId = props.prefillConnectionId;
+ if (!connectionId) return;
+ const target = { connectionId, database: props.prefillDatabase || "", ...(props.prefillSchema ? { schema: props.prefillSchema } : {}) };
+ if (typeof source === "string") {
+ store.sqlFileSource = { ...target, filePath: source };
+ } else {
+ // The web SQL file executor runs uploaded files, so upload the archive before handing it over.
+ loadingPreview.value = true;
+ errorMessage.value = "";
+ try {
+ const { previewSqlFile } = await import("@/lib/backend/http");
+ store.sqlFileSource = { ...target, preview: await previewSqlFile(source) };
+ } catch (e: any) {
+ errorMessage.value = String(e?.message || e);
+ return;
+ } finally {
+ loadingPreview.value = false;
+ }
+ }
+ open.value = false;
}
function updateMapping(sourceColumn: string, value: any) {
@@ -1631,6 +1696,7 @@ watch(rawProgressPercent, (percent) => {
<div class="min-h-0 flex-1 space-y-4 overflow-y-auto py-2 pr-1">
<div class="grid grid-cols-[minmax(0,1fr)_auto] items-center gap-2">
<input ref="fileInput" type="file" :accept="importFileExtensions.map((extension) => `.${extension}`).join(',')" :multiple="targetMode === 'create'" class="hidden" @change="handleFileInputChange" />
+ <input v-if="supportsNavicatBackupImport" ref="navicatBackupInput" data-testid="table-import-nb3-input" type="file" :accept="`.${NAVICAT_BACKUP_FORMAT}`" class="hidden" @change="handleNavicatBackupInputChange" />
<div class="flex h-10 min-w-0 items-center gap-2 rounded-md border bg-muted/20 px-3">
<span class="shrink-0 text-xs text-muted-foreground">{{ t("tableImport.target") }}</span>
<span class="min-w-0 truncate text-sm font-medium">
@@ -1710,11 +1776,20 @@ watch(rawProgressPercent, (percent) => {
data-testid="table-import-format-options"
class="grid grid-cols-2 gap-2 sm:grid-cols-3"
:class="{
- 'lg:grid-cols-6': availableFormatOptions.length === 6,
- 'lg:grid-cols-7': availableFormatOptions.length === 7,
+ 'lg:grid-cols-6': sourceFormatCards.length === 6,
+ 'lg:grid-cols-7': sourceFormatCards.length === 7,
}"
>
- <button v-for="format in availableFormatOptions" :key="format.value" type="button" class="min-h-20 rounded-md border px-3 py-2 text-left" :class="sourceFormat === format.value ? 'border-primary bg-primary/5' : 'hover:bg-muted/30'" @click="sourceFormat = format.value">
+ <button
+ v-for="format in sourceFormatCards"
+ :key="format.value"
+ type="button"
+ :data-format="format.value"
+ class="min-h-20 rounded-md border px-3 py-2 text-left"
+ :class="sourceFormat === format.value ? 'border-primary bg-primary/5' : 'hover:bg-muted/30'"
+ :disabled="loadingPreview"
+ @click="selectFormatCard(format.value)"
+ >
<component :is="format.icon" class="mb-2 h-4 w-4 text-muted-foreground" />
<div class="text-xs font-medium">{{ t(format.labelKey) }}</div>
<div class="mt-1 text-[11px] leading-snug text-muted-foreground">{{ t(format.descriptionKey) }}</div>
diff --git a/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts b/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts
index e8caed42af..0e5c8d8299 100644
--- a/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts
+++ b/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts
@@ -19,21 +19,25 @@ const mocks = vi.hoisted(() => ({
previewTableImportFile: vi.fn(),
importTableFile: vi.fn<(request: TableImportRequest, onProgress: (progress: TableImportProgress) => void) => Promise<TableImportSummary>>(),
releaseTableImportSource: vi.fn().mockResolvedValue(undefined),
+ previewSqlFile: vi.fn(),
+ store: { sqlFileSource: null as unknown },
}));
vi.mock("@/stores/connectionStore", () => ({
- useConnectionStore: () => ({
- getConfig: (id: string) => {
- if (id === "connection-1") return { id, name: "SQLite", db_type: "sqlite" };
- if (id === "postgres-1") return { id, name: "PostgreSQL", db_type: "postgres" };
- if (id === "sqlserver-1") return { id, name: "SQL Server", db_type: "sqlserver" };
- if (id === "duckdb-1") return { id, name: "DuckDB", db_type: "duckdb" };
- return undefined;
- },
- ensureConnected: mocks.ensureConnected,
- invalidateMetadataCache: vi.fn(),
- refreshObjectListTreeNode: vi.fn().mockResolvedValue(undefined),
- }),
+ useConnectionStore: () =>
+ Object.assign(mocks.store, {
+ getConfig: (id: string) => {
+ if (id === "mysql-1") return { id, name: "MySQL", db_type: "mysql" };
+ if (id === "connection-1") return { id, name: "SQLite", db_type: "sqlite" };
+ if (id === "postgres-1") return { id, name: "PostgreSQL", db_type: "postgres" };
+ if (id === "sqlserver-1") return { id, name: "SQL Server", db_type: "sqlserver" };
+ if (id === "duckdb-1") return { id, name: "DuckDB", db_type: "duckdb" };
+ return undefined;
+ },
+ ensureConnected: mocks.ensureConnected,
+ invalidateMetadataCache: vi.fn(),
+ refreshObjectListTreeNode: vi.fn().mockResolvedValue(undefined),
+ }),
}));
vi.mock("@/stores/settingsStore", () => ({
@@ -50,6 +54,7 @@ vi.mock("@/lib/backend/api", () => ({
cancelTableImport: vi.fn(),
}));
+vi.mock("@/lib/backend/http", () => ({ previewSqlFile: mocks.previewSqlFile }));
vi.mock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: vi.fn() }) }));
@@ -212,10 +217,10 @@ async function flushAsyncUpdates() {
}
}
-async function mountSourceDialog(connectionId = "connection-1") {
+async function mountSourceDialog(connectionId = "connection-1", props: Record<string, unknown> = {}) {
const container = document.createElement("div");
document.body.append(container);
- const app = createApp(defineComponent({ setup: () => () => h(TableImportDialog, { open: true, prefillConnectionId: connectionId, prefillDatabase: "main" }) }));
+ const app = createApp(defineComponent({ setup: () => () => h(TableImportDialog, { open: true, prefillConnectionId: connectionId, prefillDatabase: "main", ...props }) }));
mountedApps.push(app);
app.use(i18n);
app.mount(container);
@@ -283,6 +288,8 @@ beforeEach(() => {
return { importId: request.importId, rowsImported, totalRows: rowsImported, elapsedMs: 1 };
});
mocks.releaseTableImportSource.mockReset().mockResolvedValue(undefined);
+ mocks.previewSqlFile.mockReset();
+ mocks.store.sqlFileSource = null;
});
afterEach(() => {
@@ -347,6 +354,60 @@ describe("TableImportDialog batch selection", () => {
expect(formats?.classList.contains("lg:grid-cols-7")).toBe(false);
});
+ it.each([
+ ["mysql-1", {}, true],
+ ["postgres-1", {}, true],
+ ["mysql-1", { prefillTable: "orders" }, false],
+ ["connection-1", {}, false],
+ ])("offers the Navicat backup format only at database level of MySQL/PostgreSQL (%s, %o)", async (connectionId, props, offered) => {
+ await mountSourceDialog(connectionId, props);
+
+ expect(!!document.body.querySelector('[data-format="nb3"]')).toBe(offered);
+ expect(document.body.querySelector<HTMLInputElement>('input[type="file"]')?.accept.includes(".nb3")).toBe(offered);
+ });
+
+ it("hands a selected Navicat backup to the SQL file executor targeting this database", async () => {
+ const preview = { fileName: "shop.nb3", filePath: "/server/tmp/shop.nb3", preview: "-- Navicat backup restored by DBX" };
+ mocks.previewSqlFile.mockResolvedValue(preview);
+ const onUpdateOpen = vi.fn();
+ await mountSourceDialog("mysql-1", { prefillSchema: "", "onUpdate:open": onUpdateOpen });
+
+ const archive = new File(["nb3"], "shop.nb3");
+ const input = document.body.querySelector<HTMLInputElement>('[data-testid="table-import-nb3-input"]')!;
+ Object.defineProperty(input, "files", { configurable: true, value: [archive] });
+ input.dispatchEvent(new Event("change", { bubbles: true }));
+ await flushAsyncUpdates();
+
+ expect(mocks.previewSqlFile).toHaveBeenCalledWith(archive);
+ expect(mocks.previewTableImportFile).not.toHaveBeenCalled();
+ expect(mocks.store.sqlFileSource).toEqual({ connectionId: "mysql-1", database: "main", preview });
+ expect(onUpdateOpen).toHaveBeenCalledWith(false);
+ });
+
+ it("routes a Navicat backup picked from the generic file selector to the restore flow", async () => {
+ mocks.previewSqlFile.mockRejectedValue(new Error("Encrypted Navicat backups are not supported"));
+ const onUpdateOpen = vi.fn();
+ await mountSourceDialog("postgres-1", { "onUpdate:open": onUpdateOpen });
+
+ await selectFiles([new File(["nb3"], "app.NB3")]);
+
+ expect(mocks.previewTableImportFile).not.toHaveBeenCalled();
+ expect(mocks.store.sqlFileSource).toBeNull();
+ expect(onUpdateOpen).not.toHaveBeenCalled();
+ expect(document.body.textContent).toContain("Encrypted Navicat backups are not supported");
+ });
+
+ it("keeps a mixed selection in the table import flow instead of restoring the archive", async () => {
+ mocks.previewTableImportFile.mockImplementation(() => Promise.resolve(delimitedPreview()));
+
+ await mountSourceDialog("mysql-1");
+ await selectFiles([new File(["id,name"], "first.csv"), new File(["nb3"], "shop.nb3")]);
+
+ expect(mocks.previewSqlFile).not.toHaveBeenCalled();
+ expect(mocks.previewTableImportFile).toHaveBeenCalledTimes(2);
+ expect(mocks.store.sqlFileSource).toBeNull();
+ });
+
it("offers Parquet for DuckDB and forwards the connection context to preview", async () => {
mocks.previewTableImportFile.mockImplementation(() => Promise.resolve({ ...delimitedPreview(), fileName: "rows.parquet", fileType: "parquet", sourceFingerprint: "rows-parquet" }));
await mountSourceDialog("duckdb-1");
diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts
index f0bcc74722..5ae7926fd7 100644
--- a/apps/desktop/src/i18n/locales/az.ts
+++ b/apps/desktop/src/i18n/locales/az.ts
@@ -6534,6 +6534,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB üçün Parquet faylları",
parquetOnlyDuckdb: "Parquet idxalı yalnız DuckDB bağlantıları üçün dəstəklənir",
+ formatNb3: "Navicat ehtiyat nüsxəsi",
+ formatNb3Description: ".nb3 arxivini bu verilənlər bazasına bərpa edin",
previewRows: "Sətirlərin önbaxışı",
delimiter: "Ayırıcı",
encoding: "Kodlaşdırma",
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 4f5af0476e..bdcdd315ab 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -8540,6 +8540,8 @@ export default {
formatParquet: "Parquet",
formatParquetDescription: "Parquet files for DuckDB",
parquetOnlyDuckdb: "Parquet import is only supported for DuckDB connections",
+ formatNb3: "Navicat backup",
+ formatNb3Description: "Restore a .nb3 archive into this database",
previewRows: "Preview rows",
delimiter: "Delimiter",
decimalSeparator: "Decimal separator",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index 5240f83a15..5354285b63 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -7523,6 +7523,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "Archivos Parquet para DuckDB",
parquetOnlyDuckdb: "La importación de Parquet solo es compatible con conexiones DuckDB",
+ formatNb3: "Copia de Navicat",
+ formatNb3Description: "Restaura un archivo .nb3 en esta base de datos",
previewRows: "Preview rows",
delimiter: "Delimiter",
encoding: "Codificación",
diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.ts
index 7d4417a3fa..caed90dadc 100644
--- a/apps/desktop/src/i18n/locales/id.ts
+++ b/apps/desktop/src/i18n/locales/id.ts
@@ -7207,6 +7207,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "File Parquet untuk DuckDB",
parquetOnlyDuckdb: "Impor Parquet hanya didukung untuk koneksi DuckDB",
+ formatNb3: "Cadangan Navicat",
+ formatNb3Description: "Pulihkan arsip .nb3 ke database ini",
previewRows: "Pratinjau baris",
delimiter: "Pemisah",
decimalSeparator: "Pemisah desimal",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 7e2f504f52..68a0a34ca9 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -7328,6 +7328,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "File Parquet per DuckDB",
parquetOnlyDuckdb: "L'importazione Parquet è supportata solo per le connessioni DuckDB",
+ formatNb3: "Backup Navicat",
+ formatNb3Description: "Ripristina un archivio .nb3 in questo database",
previewRows: "Preview rows",
delimiter: "Delimiter",
encoding: "Codifica",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index 21dd9475dd..05ad2e40ce 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -7336,6 +7336,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB 用の Parquet ファイル",
parquetOnlyDuckdb: "Parquet のインポートは DuckDB 接続でのみサポートされています",
+ formatNb3: "Navicat バックアップ",
+ formatNb3Description: ".nb3 アーカイブをこのデータベースに復元します",
previewRows: "Preview rows",
delimiter: "Delimiter",
encoding: "文字コード",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 89dff29c53..f48c2ac36b 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -7359,6 +7359,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB용 Parquet 파일",
parquetOnlyDuckdb: "Parquet 가져오기는 DuckDB 연결에서만 지원됩니다",
+ formatNb3: "Navicat 백업",
+ formatNb3Description: ".nb3 아카이브를 이 데이터베이스로 복원합니다",
previewRows: "미리보기 행",
delimiter: "구분자",
encoding: "인코딩",
diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.ts
index 584acbe57d..7515e209d0 100644
--- a/apps/desktop/src/i18n/locales/pl.ts
+++ b/apps/desktop/src/i18n/locales/pl.ts
@@ -7262,6 +7262,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "Pliki Parquet dla DuckDB",
parquetOnlyDuckdb: "Import formatu Parquet jest obsługiwany tylko dla połączeń DuckDB",
+ formatNb3: "Kopia zapasowa Navicat",
+ formatNb3Description: "Przywróć archiwum .nb3 do tej bazy danych",
previewRows: "Wiersze podglądu",
delimiter: "Separator",
decimalSeparator: "Separator dziesiętny",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index f6d066b8eb..4739d0b681 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -7327,6 +7327,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "Arquivos Parquet para DuckDB",
parquetOnlyDuckdb: "A importação de Parquet é compatível apenas com conexões DuckDB",
+ formatNb3: "Backup do Navicat",
+ formatNb3Description: "Restaura um arquivo .nb3 neste banco de dados",
previewRows: "Preview rows",
delimiter: "Delimiter",
encoding: "Codificação",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 23ce578b5c..2cdd98ed25 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -8802,6 +8802,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "Файлы Parquet для DuckDB",
parquetOnlyDuckdb: "Импорт Parquet поддерживается только для подключений DuckDB",
+ formatNb3: "Резервная копия Navicat",
+ formatNb3Description: "Восстановить архив .nb3 в эту базу данных",
previewRows: "Строк предпросмотра",
delimiter: "Разделитель",
decimalSeparator: "Десятичный разделитель",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index 2d70c8b65f..5f8a88da71 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -9145,6 +9145,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "File Parquet สำหรับ DuckDB",
parquetOnlyDuckdb: "การนำเข้า Parquet รองรับเฉพาะการเชื่อมต่อ DuckDB",
+ formatNb3: "ไฟล์สำรอง Navicat",
+ formatNb3Description: "กู้คืนไฟล์ .nb3 ลงในฐานข้อมูลนี้",
previewRows: "ตัวอย่าง Rows",
delimiter: "ตัวคั่น",
decimalSeparator: "ตัวคั่นทศนิยม",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index 04cc1c6840..f2d12ae1ae 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -6414,6 +6414,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB için Parquet dosyaları",
parquetOnlyDuckdb: "Parquet içe aktarma yalnızca DuckDB bağlantılarında desteklenir",
+ formatNb3: "Navicat yedeği",
+ formatNb3Description: ".nb3 arşivini bu veritabanına geri yükleyin",
previewRows: "Satırları önizle",
delimiter: "Ayırıcı",
encoding: "Kodlama",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index ad77937270..f367a9d285 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -8507,6 +8507,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB 的 Parquet 文件",
parquetOnlyDuckdb: "Parquet 导入仅支持 DuckDB 连接",
+ formatNb3: "Navicat 备份",
+ formatNb3Description: "将 .nb3 归档恢复到此数据库",
previewRows: "预览行数",
delimiter: "分隔符",
decimalSeparator: "小数分隔符",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index ea712895e1..0dc4eea300 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -6455,6 +6455,8 @@ export default withEnglishFallback({
formatParquet: "Parquet",
formatParquetDescription: "DuckDB 的 Parquet 檔案",
parquetOnlyDuckdb: "Parquet 匯入僅支援 DuckDB 連線",
+ formatNb3: "Navicat 備份",
+ formatNb3Description: "將 .nb3 封存檔還原到此資料庫",
previewRows: "預覽列數",
delimiter: "分隔符",
encoding: "檔案編碼",
diff --git a/docs/content/docs/table-import.cn.mdx b/docs/content/docs/table-import.cn.mdx
index 7958c9975d..5593387dce 100644
--- a/docs/content/docs/table-import.cn.mdx
+++ b/docs/content/docs/table-import.cn.mdx
@@ -1,6 +1,6 @@
---
title: 表数据导入
-description: 通过向导将 CSV、TSV、文本、JSON、Excel、SQL 或 DuckDB Parquet 数据导入现有表,或按文件批量创建新表。
+description: 通过向导将 CSV、TSV、文本、JSON、Excel、SQL 或 DuckDB Parquet 数据导入现有表,或按文件批量创建新表,并可将 Navicat .nb3 备份恢复到数据库。
---
表数据导入用于把文件数据写入数据库表。DBX 会先解析和预览文件,再让你确认解析选项、目标表、字段映射和执行方式,而不是选中文件后立即写入。
@@ -29,6 +29,7 @@ MongoDB Collection 不走这条关系型导入流程。请在 Collection 文档
| Excel | 支持 `.xlsx`、`.xlsm` 和 `.xls`,可选择工作表 |
| SQL | 包含字面量 `INSERT INTO ... VALUES` 语句的 `.sql` 脚本,每个文件对应一张表 |
| Parquet | `.parquet` 文件,仅在目标连接为 DuckDB 时提供 |
+| Navicat 备份 | `.nb3` 归档,仅在 MySQL 和 PostgreSQL 连接的数据库级入口提供,参见 [Navicat 备份](#navicat-备份) |
SQL 导入只接受字面量 `INSERT INTO ... VALUES` 行;表达式、`REPLACE`、`INSERT IGNORE`、`INSERT ... SELECT` 等无法无损改写的内容会被拒绝,以保留数据和语句语义。
@@ -40,6 +41,14 @@ Desktop 直接读取所选本地文件;Docker/Web 会先把浏览器选择的
Parquet 导入使用所选 DuckDB 连接的原生 Parquet 读取能力,仍然沿用预览、字段映射、新建表、追加和清空后导入流程;其他数据库类型不会提供 Parquet 导入格式。大型 Parquet 文件按有界批次读取,嵌套值仍受目标字段类型和 DuckDB 类型转换规则约束。
+## Navicat 备份
+
+在 MySQL 或 PostgreSQL 连接上从数据库(而不是某张表)打开表数据导入时,来源步骤还会提供 **Navicat 备份**。点击该卡片,或通过 **选择文件** 选中 `.nb3` 文件后,DBX 会打开 [SQL 文件执行](/cn/docs/sql-file),并自动填入相同的连接、数据库和归档文件,让备份直接恢复到当前数据库。
+
+![导入数据对话框中的 Navicat 备份格式](/screenshots/table-import-navicat-nb3.png)
+
+归档会作为整库恢复脚本执行,而不走字段映射向导:先删除并重建归档中的表、视图和例程,再写入数据,最后创建索引、约束和触发器。建议先恢复到空库或测试库,并为目标库保留备份。不支持加密的 Navicat 归档。同样的归档也可以在 [数据库备份](/cn/docs/database-backup) 中通过 **从文件恢复** 还原。
+
## 导入向导
<Steps>
diff --git a/docs/content/docs/table-import.mdx b/docs/content/docs/table-import.mdx
index 1e2720ffdf..b9120adfc2 100644
--- a/docs/content/docs/table-import.mdx
+++ b/docs/content/docs/table-import.mdx
@@ -1,6 +1,6 @@
---
title: Table Import
-description: Use a guided workflow to import CSV, TSV, text, JSON, Excel, SQL, or DuckDB Parquet data into an existing table or create new tables in batches.
+description: Use a guided workflow to import CSV, TSV, text, JSON, Excel, SQL, or DuckDB Parquet data into an existing table or create new tables in batches, and restore Navicat .nb3 backups into a database.
---
Table Import writes file data into database tables. DBX parses and previews the source first, then asks you to review parsing options, the target, column mappings, and execution settings before any rows are written.
@@ -29,6 +29,7 @@ Create-table mode accepts multiple files at once. Excel workbooks are expanded i
| Excel | `.xlsx`, `.xlsm`, and `.xls`, with worksheet selection |
| SQL | `.sql` scripts containing literal `INSERT INTO ... VALUES` statements for one table |
| Parquet | `.parquet` files, available when the target connection is DuckDB |
+| Navicat backup | `.nb3` archives, available from the database-level entry of MySQL and PostgreSQL connections; see [Navicat Backups](#navicat-backups) |
SQL import accepts only literal `INSERT INTO ... VALUES` rows. Expressions, `REPLACE`, `INSERT IGNORE`, `INSERT ... SELECT`, and other constructs that cannot be rewritten losslessly are rejected so data and statement semantics are preserved.
@@ -40,6 +41,14 @@ Desktop reads selected local files directly. Docker/Web uploads browser-selected
Parquet import uses the selected DuckDB connection's native Parquet reader. The same preview, mapping, new-table, append, and truncate workflow applies, while other database types do not offer Parquet as an import format. Large Parquet sources are read in bounded batches; nested values remain subject to the target column type and DuckDB conversion rules.
+## Navicat Backups
+
+When Table Import is opened from a database (not from a table) on a MySQL or PostgreSQL connection, the source step also offers **Navicat backup**. Choose the card, or pick a `.nb3` file with **Select File**, and DBX opens [SQL File Execution](/en/docs/sql-file) with the same connection, database, and archive already filled in, so the backup restores straight into the database you started from.
+
+![Navicat backup format in the Import Data dialog](/screenshots/table-import-navicat-nb3.png)
+
+The archive is restored as a whole database script rather than through the column-mapping wizard: it drops and recreates the archived tables, views, and routines, loads their rows, then adds indexes, constraints, and triggers. Restore into an empty or disposable database first, and keep a backup of the target. Encrypted Navicat archives are not supported. The same archives can also be restored from [Database Backup](/en/docs/database-backup) with **Restore from file**.
+
## Import Wizard
<Steps>
diff --git a/docs/public/screenshots/table-import-navicat-nb3.png b/docs/public/screenshots/table-import-navicat-nb3.png
new file mode 100644
index 0000000000..2a0c2b93ba
Binary files /dev/null and b/docs/public/screenshots/table-import-navicat-nb3.png differ