Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to gorm #13

Open
rgautam98 opened this issue May 20, 2019 · 1 comment
Open

Port to gorm #13

rgautam98 opened this issue May 20, 2019 · 1 comment

Comments

@rgautam98
Copy link

Can I use this with the gorm(https://github.com/jinzhu/gorm).

If yes, can you give any example code(noob here).

@zsichen
Copy link

zsichen commented Mar 18, 2020

Hi, I'm trying to use this on gorm too. And I made a wrapper on it try to act as a driver.
but I got some error.
image
and here is my code

package driver

import (
	"database/sql"
	"database/sql/driver"
	"github.com/go-sql-driver/mysql"
	"github.com/tsenart/nap"
)

type MySQLSplitDriver struct {
	mysql.MySQLDriver
}

func (d MySQLSplitDriver) Open(dsn string) (driver.Conn, error) {
	return nap.Open("mysql", dsn)
}

func init() {
	sql.Register("mysqlsplit", &MySQLSplitDriver{})
}

I think this might be a decent way to use it. Could you make a fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants