From 5932b0afc3b797e5444c9ad87608398c4f9fbca3 Mon Sep 17 00:00:00 2001 From: Wenchao Zeng Date: Thu, 18 Nov 2021 00:56:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=8C=87=E5=AE=9A=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 26 +++++++++++++++---- note.txt | 1 - .../sqldataprocessor/core/ExportExecutor.java | 2 ++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index fb14e86..c665c47 100644 --- a/README.md +++ b/README.md @@ -22,23 +22,25 @@ # import /Users/xxx/Downloads/xxx.xlsx ``` -## `# xxx` 指定一个数据库连接名称和一个SQL, 以`;`分号结束. select, insert, update, delete, create table都支持. +## 使用 `# xxx` 来指定一个数据库连接名称和紧跟着一个或多个SQL语句, 以最后一个SQL语句执行结果作为本次的结果 ```sql # local_db +set @input = 'hello'; +update test_table set a = 2 where a = 1; select temp.name, temp2.text from test_table temp left join test_table2 temp2 on temp2.id = temp.temp2_id where - text = 'hello' + text = @input order by temp.id desc limit 10 ; ``` -## `as $xxx` 指定结果集的名称, 若不指定, 则默认结果集名称为$table +## 使用 `as $xxx` 来指定结果集的名称, 若不指定, 则默认结果集名称为$table ```sql # import /Users/xxx/Downloads/xxx.xlsx as $table1 @@ -49,7 +51,7 @@ select from test_table temp; ``` -## SQL中可以引用之前的结果集 +## 在SQL中可以使用 `$xxx` 的方式来引用之前的结果集 ```sql # import /Users/xxx/Downloads/xxx.xlsx @@ -75,10 +77,24 @@ left join test_table3 temp3 on temp3.id = temp.id2 select * from $table temp; ``` -## `##` 注释 +## 使用 `# export` 来导出上一个执行的结果集 ```sql +-- 使用默认路径和文件名 +# export +-- 指定导出文件的名称 +# export 这是一个文件名 + +-- 使用指定的完整路径 +# export /Users/wenchaozeng/Downloads/aa.csv +``` + +## 使用 `##` 和 `--` 来添加注释 + +```sql + +-- 这是注释 ## 这是注释 # local_db select diff --git a/note.txt b/note.txt index ea5b87a..413a9a7 100644 --- a/note.txt +++ b/note.txt @@ -1,2 +1 @@ 待开发功能: - \ No newline at end of file diff --git a/src/main/java/com/zwc/sqldataprocessor/core/ExportExecutor.java b/src/main/java/com/zwc/sqldataprocessor/core/ExportExecutor.java index 2a015c8..1d26741 100644 --- a/src/main/java/com/zwc/sqldataprocessor/core/ExportExecutor.java +++ b/src/main/java/com/zwc/sqldataprocessor/core/ExportExecutor.java @@ -24,6 +24,8 @@ public static String export(String resultName, DataList table, String path) { // 确定导出文件路径 if (path == null) { path = String.format("./output/%s.csv", resultName); + } else if (!path.contains("/") && !path.contains("\\")) { + path = String.format("./output/%s.csv", path); } // 执行导出