Add more configurable constructors for all adapters

pull/20/head
Vinícius Garcia 2022-04-11 20:52:40 -03:00
parent b44c7e8500
commit 3eb5a72123
4 changed files with 16 additions and 1 deletions

View File

@ -11,6 +11,11 @@ import (
_ "github.com/go-sql-driver/mysql"
)
// NewFromSQLDB builds a ksql.DB from a *sql.DB instance
func NewFromSQLDB(db *sql.DB) (ksql.DB, error) {
return ksql.NewWithAdapter(NewSQLAdapter(db), "mysql")
}
// New instantiates a new KissSQL client using the "mysql" driver
func New(
_ context.Context,

View File

@ -11,7 +11,7 @@ import (
_ "github.com/lib/pq"
)
// NewFromPgxPool builds a ksql.DB from a *pgxpool.Pool instance.
// NewFromPgxPool builds a ksql.DB from a *pgxpool.Pool instance
func NewFromPgxPool(pool *pgxpool.Pool) (db ksql.DB, err error) {
return ksql.NewWithAdapter(NewPGXAdapter(pool), "postgres")
}

View File

@ -11,6 +11,11 @@ import (
_ "github.com/mattn/go-sqlite3"
)
// NewFromSQLDB builds a ksql.DB from a *sql.DB instance
func NewFromSQLDB(db *sql.DB) (ksql.DB, error) {
return ksql.NewWithAdapter(NewSQLAdapter(db), "sqlite3")
}
// New instantiates a new KissSQL client using the "sqlite3" driver
func New(
_ context.Context,

View File

@ -11,6 +11,11 @@ import (
_ "github.com/denisenkom/go-mssqldb"
)
// NewFromSQLDB builds a ksql.DB from a *sql.DB instance
func NewFromSQLDB(db *sql.DB) (ksql.DB, error) {
return ksql.NewWithAdapter(NewSQLAdapter(db), "sqlserver")
}
// New instantiates a new KissSQL client using the "sqlserver" driver
func New(
_ context.Context,