bindings/go/go-driver-db.mdx
Generate Go SDK for the Turso - SQLite-compatible embedded database written in Rust. You must use bindings_db.go bridge from Go to C API.
turso_statement_parameters_count methodBEGIN always as SQLite and Turso doesn't have other transaction modes except from SNAPSHOT ISOLATIONuint64(^int64(0)) - use math.MaxInt64 instead_ interface{ Done() <-chan struct{} } - use ctx context.Context insteadpackage turso
// define all package level errors here
var (
TursoStmtClosedErr = errors.New("turso: statement closed") // provide short but concise error message
...
)
// define all package level structs here
struct tursoDbDriver { ... }
// register driver
func init() {
sql.Register("turso", &tursoDbDriver{})
}
// Extra constructor for *tursoDbConnection instance which can be used to intergrate with turso Db driver
// extr_io parameter is the arbitrary IO function which will be executed together with turso_statement_run_io
func NewConnection(conn TursoConnection, extraIo func() error) *tursoDbConnection {
}
// Implement sql.Driver methods
...
The SDK should has following components under the hood:
type tursoDbConnection struct { } - wrapper which holds connection to the turso and protect it against concurrent usetype tursoDbStatement struct { } - wrapper which holds prepared statement to the turso and protect it against concurrent usetype tursoDbRows struct { } - wrapper which holds prepared statement and provide sqld/database compatible methods to iterate over rows of the statementtype tursoDbDriver struct { } - type to register in the sql/database as drivertype tursoDbResult struct { } - type implementing driver.Result interfacetype tursoDbTx struct { } - type implementing driver.Tx interface<path>[?experimental=<string>&async=0|1]Exec* family of methods. Use turso_connection_prepare_first method for thatInspect go sql driver documentation and follow it during implementation:
<Shell cmd="go doc -all sql" /> </Code> </Output>