douhuifen9942
douhuifen9942
2016-10-08 02:39

golang同时连接2个不同类型的数据库

  • IT行业问题
  • 计算机技术
  • it技术
  • 编程语言问答
  • 互联网问答
已采纳

I need to connect mysql and oracle at same time for a database related application. From the document I learned that in go the database drivers are initialized in "init()" function. So I want to know if I import 2 different database drivers, does the later driver will override the former one?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • douben6670 douben6670 5年前

    There's no problem importing both because the drivers use different names. The driver name is the first argument to sql.Open.

    If they should happen to use the same name, then the driver registration function panics.

    点赞 评论 复制链接分享

为你推荐