mirror of
https://github.com/nghialt/xun.git
synced 2025-12-24 13:18:14 +08:00
Readme: more connection demo
This commit is contained in:
35
README.md
35
README.md
@@ -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
3
docs/capsule.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Xun Capsule References
|
||||
|
||||
The capsule references
|
||||
Reference in New Issue
Block a user