Skip to content

Instantly share code, notes, and snippets.

@leopard627
Created July 11, 2017 07:40
Show Gist options
  • Select an option

  • Save leopard627/dabfa413823712850b26404849b37c50 to your computer and use it in GitHub Desktop.

Select an option

Save leopard627/dabfa413823712850b26404849b37c50 to your computer and use it in GitHub Desktop.
Switch to another database:
orm.RegisterDataBase("db1", "mysql", "root:root@/orm_db2?charset=utf8")
orm.RegisterDataBase("db2", "sqlite3", "data.db")
o1 := orm.NewOrm()
o1.Using("db1")
o2 := orm.NewOrm()
o2.Using("db2")
// After switching database
// The API calls of this Ormer will use the new database
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment