@lark-apaas/miaoda-cli 0.1.0-alpha.d98ea14 → 0.1.0-alpha.e245354
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -160,10 +160,10 @@ Examples:
|
|
|
160
160
|
`);
|
|
161
161
|
dataCmd
|
|
162
162
|
.command("export")
|
|
163
|
-
.description("将指定表的数据导出为 CSV / JSON 文件")
|
|
163
|
+
.description("将指定表的数据导出为 CSV / JSON / SQL 文件")
|
|
164
164
|
.usage("<table> [flags]")
|
|
165
165
|
.argument("<table>", "表名(无需带 schema 前缀)")
|
|
166
|
-
.option("--format <fmt>", "导出格式 csv / json,默认 csv")
|
|
166
|
+
.option("--format <fmt>", "导出格式 csv / json / sql,默认 csv(sql 输出 INSERT 语句,要求表已注册元数据)")
|
|
167
167
|
.option("-f, --file <path>", "输出文件路径,默认 <table>.<format>")
|
|
168
168
|
.option("--limit <n>", "最多导出行数(不超过 5000)")
|
|
169
169
|
.action(async (table, opts) => {
|
|
@@ -181,6 +181,9 @@ Examples:
|
|
|
181
181
|
$ miaoda db data export users --format json
|
|
182
182
|
✓ Exported 120 rows to ./users.json
|
|
183
183
|
|
|
184
|
+
$ miaoda db data export users --format sql
|
|
185
|
+
✓ Exported 120 rows to ./users.sql
|
|
186
|
+
|
|
184
187
|
$ miaoda db data export users -f /tmp/u.csv --limit 1000
|
|
185
188
|
✓ Exported 1000 rows to /tmp/u.csv
|
|
186
189
|
|
|
@@ -135,12 +135,15 @@ function resolveFormat(explicit, ext, scope, fallback) {
|
|
|
135
135
|
return "csv";
|
|
136
136
|
if (raw === "json")
|
|
137
137
|
return "json";
|
|
138
|
+
// sql 仅 export 路径接受 —— import 端后端仍只支持 csv/json。
|
|
139
|
+
if (raw === "sql" && scope === "export")
|
|
140
|
+
return "sql";
|
|
138
141
|
const code = scope === "import" ? "IMPORT_FORMAT_UNSUPPORTED" : "EXPORT_FORMAT_UNSUPPORTED";
|
|
139
142
|
throw new error_1.AppError(code, `Unrecognized format '${raw || "(unspecified)"}'`, {
|
|
140
143
|
next_actions: [
|
|
141
144
|
scope === "import"
|
|
142
145
|
? "Supported formats: .csv, .json. Convert the file first, or rename with the correct extension."
|
|
143
|
-
: "Supported formats: csv, json. Pass --format csv|json.",
|
|
146
|
+
: "Supported formats: csv, json, sql. Pass --format csv|json|sql.",
|
|
144
147
|
],
|
|
145
148
|
});
|
|
146
149
|
}
|