GORM은 Go 프로그래밍 언어를 위한 객체 관계형 매핑 도구입니다. 객체 지향 도메인 모델을 관계형 데이터베이스에 매핑하기 위한 프레임워크를 제공합니다.
오픈소스 Spanner Dialect(SpannerDialect)를 사용하여 GoogleSQL 언어 데이터베이스를 GORM과 통합할 수 있습니다.
Spanner GoogleSQL 언어 데이터베이스에 GORM 설정
애플리케이션에서 GoogleSQL GORM 언어를 사용하려면 GORM이 초기화된 파일에 다음 가져오기 문을 추가합니다.
import (
"fmt"
"gorm.io/gorm"
_ "github.com/googleapis/go-sql-spanner"
spannergorm "github.com/googleapis/go-gorm-spanner"
)
dsn := fmt.Sprintf("projects/%s/instances/%s/databases/%s", projectId, instanceId, databaseId),
db, err := gorm.Open(spannergorm.New(spannergorm.Config{DriverName: "spanner", DSN: dsn}), &gorm.Config{})
```
See the
[GORM with GoogleSQL documentation][go-driver-documentation]
for more connection options for Spanner.
## Use GORM with Spanner GoogleSQL-dialect databases
For more information about the features and recommendations for using
GORM with Spanner, consult the [reference documentation][spanner-gorm-github]
on GitHub.
## What's next {: #whats-next}
* Checkout the [sample application][gorm-gsql-sample-application] using
GORM with GoogleSQL and Spanner.
* Learn more about [GORM][gorm].
* [File a GitHub issue][spanner-gorm-issue] to report a bug or ask a question
about using GORM with Spanner with GoogleSQL.
* Learn more about [Integrate Spanner with GORM (
PostgreSQL dialect)](/spanner/docs/use-gorm-postgresql).