Skip to content

Commit

Permalink
支持指定文件名称
Browse files Browse the repository at this point in the history
  • Loading branch information
WenchaoZeng committed Nov 17, 2021
1 parent 6edd446 commit 5932b0a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -49,7 +51,7 @@ select
from test_table temp;
```

## SQL中可以引用之前的结果集
## 在SQL中可以使用 `$xxx` 的方式来引用之前的结果集

```sql
# import /Users/xxx/Downloads/xxx.xlsx
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion note.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
待开发功能:

Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

// 执行导出
Expand Down

0 comments on commit 5932b0a

Please sign in to comment.