github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/sql_unwrap.go (about)

     1  package ydb
     2  
     3  import (
     4  	"database/sql"
     5  
     6  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
     7  	"github.com/ydb-platform/ydb-go-sdk/v3/internal/xsql"
     8  )
     9  
    10  func Unwrap[T *sql.DB | *sql.Conn](v T) (*Driver, error) {
    11  	c, err := xsql.Unwrap(v)
    12  	if err != nil {
    13  		return nil, xerrors.WithStackTrace(err)
    14  	}
    15  	d.connectorsMtx.RLock()
    16  	defer d.connectorsMtx.RUnlock()
    17  
    18  	return d.connectors[c], nil
    19  }