LoginSignup
0
0

More than 5 years have passed since last update.

gormでGAEから同プロジェクトのcloudSQLに接続

Posted at

答え

import (
    "github.com/jinzhu/gorm"
    _ "github.com/jinzhu/gorm/dialects/mysql"
)

db, err = gorm.Open("mysql", "ユーザー名:パスワード@unix(/cloudsql/インスタンス接続名)/DB名")

*インスタンス接続名はプロジェクトid:リージョン:インスタンス名

参考

go-sql-driver/mysql
*gormは内部的にgo-sql-driver/mysqlを使用しているので、困ったらこれ見ると良いと思います。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0