QthCN
QthCN

Reputation: 137

golang connect 2 different type database at same time

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?

Upvotes: 1

Views: 1826

Answers (1)

Thundercat
Thundercat

Reputation: 121149

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.

Upvotes: 2

Related Questions