nap icon indicating copy to clipboard operation
nap copied to clipboard

Port to gorm

Open rgautam98 opened this issue 5 years ago • 1 comments

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

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

rgautam98 avatar May 20 '19 09:05 rgautam98

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?

zsichen avatar Mar 18 '20 08:03 zsichen