Skip to content

Commit 22887f2

Browse files
committed
update README
1 parent 1b696de commit 22887f2

File tree

1 file changed

+39
-10
lines changed

1 file changed

+39
-10
lines changed

README.md

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,25 @@
22

33
## How to use
44

5-
## Extractor
5+
1. Extract the queries [statically](#static-extractor) or [dynamically](#dynamic-extractor)
6+
2. [Get your table schema](#getting-table-schemas)
7+
3. [Generate cache plan](#generate-cache-plan)
8+
4. [Generate the driver](#generate-the-driver)
69

7-
### Static Extractor
10+
### Extractor
11+
12+
#### Static Extractor
813

914
<!-- TODO: rewrite for production usage (not need to clone repository) -->
1015

1116
- `--out` represents the destination file of the extracted queries.
1217
- Set to `extracted.sql` by default
1318

1419
```sh
15-
go run cli/main.go extract --out extracted.sql /path/to/your/codebase/dir
20+
go run cli/*.go extract --out extracted.sql /path/to/your/codebase/dir
1621
```
1722

18-
### Dynamic Extractor
23+
#### Dynamic Extractor
1924

2025
1. add import statement
2126

@@ -38,27 +43,51 @@ func main() {
3843
4. running your application
3944
5. access `http://localhost:39393` and get the query list
4045

41-
## Getting Table Schemas
46+
### Getting Table Schemas
47+
48+
If you do not have the `schema.sql`, you can generate it by the command below (you should change the auth info)
4249

4350
```sh
44-
DATABASE='isupipe'
45-
mysql -u root -ppass -h 127.0.0.1 -N -e "SHOW TABLES FROM $DATABASE" | while read table; do mysql -u root -ppass -h 127.0.0.1 -e "SHOW CREATE TABLE $DATABASE.\`$table\`" | awk 'NR>1 {$1=""; print substr($0,2) ";"}' | sed 's/\\n/\n/g'; done > schema.sql
51+
DATABASE='YOUR_DATABASE'
52+
USER='YOUR_DATABASE_USER'
53+
PASSWORD='YOUR_DATABASE_PASSWORD'
54+
HOST='YOUR_DATABASE_HOST'
55+
mysql -u "$USER" -p"$PASSWORD" -h "$HOST" -N -e "SHOW TABLES FROM $DATABASE" | while read table; do mysql -u "$USER" -p"$PASSWORD" -h "$HOST" -e "SHOW CREATE TABLE $DATABASE.\`$table\`" | awk 'NR>1 {$1=""; print substr($0,2) ";"}' | sed 's/\\n/\n/g'; done > schema.sql
4656
```
4757

48-
## Generate Cache Plan
58+
### Generate Cache Plan
4959

5060
<!-- TODO: rewrite for production usage (not need to clone repository) -->
5161

62+
```sh
63+
go run cli/*.go analyze --sql extracted.sql --schema schema.sql --out isuc.yaml
64+
```
65+
5266
- `--sql` represents extracted queries (via the static/dynamic extractor)
5367
- Set to `extracted.sql` by default
68+
- `--schema` represents the table schema sql
69+
- Set to `schema.sql` by default
5470
- `--out` is the destination file of the cache plan
5571
- Set to `isuc.yaml` by default
5672

73+
### Generate the driver
74+
75+
<!-- TODO: rewrite for production usage (not need to clone repository) -->
76+
5777
```sh
58-
go run cli/main.go analyze --sql extracted.sql --out isuc.yaml
78+
go run cli/*.go generate --plan isuc.yaml --schema schema.sql <dist>
5979
```
6080

61-
### Format
81+
- `--plan` represents generated cache plan
82+
- Set to `isuc.yaml` by default
83+
- `--schema` represents the table schema sql
84+
- Set to `schema.sql` by default
85+
- `<dist>` represents the destination folder (must exist) that the generated driver will be stored into
86+
87+
## Appendix
88+
89+
90+
### Cache Plan Format
6291

6392
```ts
6493
type Format = {

0 commit comments

Comments
 (0)