You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: support Spanner PostgreSQL databases
Adds support for using the gorm PostgreSQL dialect with Spanner. Connections to
Spanner use the Spanner database/sql driver, and not one of the PostgreSQL
database drivers (e.g. it does not use pgx). Using this dialect with Spanner
does not require the use of PGAdapter.
* chore: address review comments
* chore: update dependencies
return fmt.Errorf("failed to open database connection: %v\n", err)
62
+
}
63
+
varmsgstring
64
+
iferr:= db.Raw("SELECT $1::varchar as greeting", "Hello World from Spanner PostgreSQL!").Scan(&msg).Error; err != nil {
65
+
return fmt.Errorf("failed to execute query: %v", err)
66
+
}
67
+
fmt.Println(msg)
68
+
69
+
returnnil
36
70
}
37
71
```
38
72
39
-
### Connection URL Properties
73
+
See the [PostgreSQL samples directory](postgresql/samples) for more examples for how to use this library with a Spanner
74
+
PostgreSQL database.
75
+
76
+
## Connection URL Properties
40
77
41
78
The Cloud Spanner GORM supports the following connection URL properties
42
79
43
-
####Commonly Used Properties
80
+
### Commonly Used Properties
44
81
- credentials (String): File name for the credentials to use. The connection will use the default credentials of the environment if no credentials file is specified in the connection string. Example: `projects/my-project/instances/my-instance/databases/my-db;credentials=/path/to/credentials.json`
45
82
- optimizerVersion (String): Sets the default query optimizer version to use for this connection. See also https://cloud.google.com/spanner/docs/query-optimizer/query-optimizer-versions.
46
83
- isolationLevel (String): Sets the default isolation level for read/write transaction. The default is `sql.LevelSerializable`. Other supported values are `sql.LevelRepeatableRead`. Example: `fmt.Sprintf("projects/my-project/instances/my-instance/databases/my-db;isolationLevel=%s", sql.LevelRepeatableRead)`
@@ -51,15 +88,15 @@ minimum and maximum number of sessions for `gorm`.
51
88
52
89
See https://cloud.google.com/spanner/docs/sessions#multiplexed_sessions for more information about multiplexed sessions.
53
90
54
-
####Advanced Properties
91
+
### Advanced Properties
55
92
- numChannels (int): Sets the number of gRPC channels to use. Defaults to 4.
56
93
- retryAbortsInternally (boolean): Boolean that indicates whether the connection should automatically retry aborted errors. The default is true.
57
94
- disableRouteToLeader (boolean): Boolean that indicates if all the requests of type read-write and PDML need to be routed to the leader region. The default is false.
58
95
- usePlainText (boolean): : Boolean that indicates whether the connection should use plain text communication or not. Set this to true to connect to local mock servers that do not use SSL. Example: `projects/test-project/instances/test-instance/databases/test-db;usePlainText=true`
0 commit comments