Skip to content

Commit 4ba4055

Browse files
committed
docs: 完善README 发布1.2版本
1 parent 9cd6168 commit 4ba4055

File tree

5 files changed

+153
-14
lines changed

5 files changed

+153
-14
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.PHONY: all build run
22
.DEFAULT_GOAL := run
3-
3+
export MAKEFLAGS := -s
44
all: build run
55

66
build:

README.md

+151-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,158 @@
11
# gosql
22

3-
用golang实现的数据库,没有涉及过多的数据结构和智能判断.
3+
![alt text](./shots/image.png)
44

5-
包括以下内容:
5+
使用**Go**语言实现的简单数据库应用,包含以下特点:
66

7-
基于B+树的命令语法解析
8-
基于Go内置的数据库类型支持
9-
基于Go文件IO的数据库基础功能
10-
外置命令与内置Shell实现
11-
简单的多进程多用户的数据库锁
12-
完整的Log体系
13-
基于Go内置多线程的性能优化
14-
AES加密
7+
1. 基于B+树的命令语法解析
8+
2. 基于Go内置的数据库类型支持
9+
3. 基于Go文件IO的数据库基础功能
10+
4. 外置命令与内置Shell实现
11+
5. 简单的多进程多用户的数据库锁
12+
6. 完整的Log体系
13+
7. 基于Go内置多线程的性能优化
14+
8. AES加密
1515

16-
TODO:
16+
# Usage
1717

18-
基于Go的网络接口服务 可以通过Java与Spring进行对接的库(下次也不一定)
18+
## 原生命令行
19+
gosql使用原生命令行式登陆:
20+
21+
![alt text](./shots/image2.png)
22+
23+
你可以使用如下命令登陆(请注意,第一次登陆只能使用root账户):
24+
25+
```shell
26+
gosql -u [username] -p
27+
```
28+
29+
更多用法参考`-h`输出
30+
31+
## SQL语法
32+
33+
gosql支持基本的原生sql语法(create,drop,show,select,insert,update,delete及where条件语句和and or判定),同时支持首字母大写,全大写,全小写三种语法格式.
34+
35+
> [!CAUTION]\
36+
> gosql的where查询比较原始,只支持单个and/or查询,如
37+
> "name=kali and age=10 and dog=true"是合法的
38+
> "name=kali and age=10 **or** dog=true"是**非法**的.
39+
40+
gosql支持string,int,float,boolean四种数据格式(还有一种string[],但是已经被废弃)
41+
42+
gosql支持引号用法,及`"name"="J.K Linux" and age="10" and "is_man"=false`是合法的
43+
44+
### 数据库语法:
45+
46+
```sql
47+
#创建数据库
48+
create database [name]
49+
#使用数据库
50+
use database [name]
51+
#删除数据库
52+
drop database [name]
53+
```
54+
55+
### 表语法:
56+
57+
```sql
58+
#创建表
59+
create table [name] [column1]=[data_type1],[column2]=[data_type2]...
60+
#删除表
61+
drop database [name]
62+
```
63+
64+
### Select语法
65+
66+
```sql
67+
select [column1],[column2]... from [table1],[table2]... \
68+
(where [column1]=[data1] and/or [column2]=[data2] and/or ...)
69+
```
70+
71+
e.g:
72+
73+
```sql
74+
select age from student where age=10 and is_man=true
75+
```
76+
77+
### Update语法
78+
79+
```sql
80+
update [table1],[table2]... set [column1]=[data1],[column2]=[data2]... \
81+
(where [column1]=[data1] and/or [column2]=[data2] and/or ...)
82+
```
83+
84+
e.g:
85+
86+
```sql
87+
update student set is_man=false where age=10 and name="old_e"
88+
```
89+
90+
### Insert语法
91+
92+
> [!CAUTION]\
93+
> gosql不支持为字段创建默认值,所以你需要添加所有字段所有值
94+
95+
```sql
96+
insert into [table1],[table2]... values [data1],[data2]...
97+
```
98+
99+
e.g:
100+
101+
```sql
102+
insert into student values "howxu",66,true
103+
```
104+
105+
### Delete语法
106+
107+
```sql
108+
delete from [table1],[table2]... \
109+
(where [column1]=[data1] and/or [column2]=[data2] and/or ...)
110+
```
111+
112+
e.g:
113+
114+
```sql
115+
delete from student where name="howxu" or "age"="14"
116+
```
117+
118+
### 其它语法
119+
120+
```shell
121+
#修改本用户密码
122+
passwd
123+
#打印用户名
124+
whoami
125+
#退出
126+
exit
127+
```
128+
129+
# 开发
130+
131+
欢迎Issue和PR
132+
133+
> [!NOTE]\
134+
> Go 1.23.3
135+
> Windows 11 24H2
136+
> Mingw make 4.4.1
137+
138+
## 构建
139+
140+
```shell
141+
make build
142+
```
143+
144+
你可以在`build`文件夹下找到`gosql.exe`文件
145+
146+
## 测试
147+
148+
```shell
149+
make ARGS="-u [username] -p"
150+
```
151+
152+
具体内容参考[本项目Makefile](./Makefile)
153+
154+
# 展望未来
155+
156+
基于Go的网络接口服务
157+
可以通过Java与Spring进行对接的库(下次也不一定)
19158

core/core.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/HowXu/gosql/util"
1313
)
1414

15-
var Version string = "1.1"
15+
var Version string = "1.2"
1616
var plainText = "56We55qE5L2O6K+t"
1717

1818
func Init() {

shots/image.png

1.82 KB
Loading

shots/image2.png

21.4 KB
Loading

0 commit comments

Comments
 (0)