Readme: more connection demo

This commit is contained in:
Max
2021-03-22 16:28:49 +08:00
parent e7544435e1
commit d1dbe89a57
2 changed files with 36 additions and 2 deletions

View File

@@ -78,8 +78,7 @@ import (
func main(){
db := capsule.New().AddConn("primary",
"postgres",
db := capsule.New().AddConn("primary", "postgres",
"postgres://postgres:123456@127.0.0.1/xun?sslmode=disable&search_path=xun",
)
@@ -95,6 +94,38 @@ func main(){
}
```
MySQL database
```golang
db := capsule.New().AddConn("primary", "mysql",
"root:123456@tcp(192.168.31.119:3307)/xun?charset=utf8mb4&parseTime=True&loc=Local",
)
```
SQLite database
```golang
db := capsule.New().AddConn("primary","sqlite3",
"file:///data/xun.db",
)
```
Multiple connections
```golang
db := capsule.New().
AddConn("primary", "mysql",
"root:123456@tcp(192.168.31.119:3307)/xun?charset=utf8mb4&parseTime=True&loc=Local",
).
AddReadConn("secondary", "mysql",
"readonly:123456@tcp(192.168.31.119:3306)/xun?charset=utf8mb4&parseTime=True&loc=Local"
)
```
Read more [Xun Capsule References](docs/capsule.md)
### Using The Schema Interface
```golang

3
docs/capsule.md Normal file
View File

@@ -0,0 +1,3 @@
# Xun Capsule References
The capsule references