https://github.com/ydb-platform/gorm-driver
GORM YDB driver
https://github.com/ydb-platform/gorm-driver
Last synced: 29 days ago
JSON representation
GORM YDB driver
- Host: GitHub
- URL: https://github.com/ydb-platform/gorm-driver
- Owner: ydb-platform
- License: apache-2.0
- Created: 2022-12-21T13:08:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-29T10:50:47.000Z (about 1 year ago)
- Last Synced: 2025-04-29T11:43:21.588Z (about 1 year ago)
- Language: Go
- Size: 369 KB
- Stars: 5
- Watchers: 2
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# GORM YDB Driver
YDB support for GORM
[](https://github.com/ydb-platform/ydb/blob/main/LICENSE)
[](https://github.com/ydb-platform/gorm-driver/releases)
[](https://pkg.go.dev/github.com/ydb-platform/gorm-driver)


[](https://goreportcard.com/report/github.com/ydb-platform/gorm-driver)
[](https://app.codecov.io/gh/ydb-platform/gorm-driver)

[](https://github.com/ydb-platform/ydb-go-sdk/tree/master/examples/basic/gorm)
[](https://t.me/ydb_en)
[](https://ydb.tech)
## Quick Start
You can simply test your connection to your database with the following:
```go
package main
import (
ydb "github.com/ydb-platform/gorm-driver"
"gorm.io/gorm"
)
type User struct {
Name string `gorm:"primarykey"`
Age int
}
func main() {
db, err := gorm.Open(ydb.Open("grpc://localhost:2136/local"))
if err != nil {
panic("failed to connect database")
}
// Auto Migrate
db.AutoMigrate(&User{})
// Insert
db.Create(&User{Name: "Angeliz", Age: 18})
// Select
db.Find(&User{}, "name = ?", "Angeliz")
// Batch Insert
user1 := User{Name: "Charles", Age: 12}
user2 := User{Name: "Feynman", Age: 13}
user3 := User{Name: "Michael", Age: 14}
users := []User{user1, user2, user3}
db.Create(&users)
// ...
}
```