zeroshade commented on code in PR #3204: URL: https://github.com/apache/arrow-adbc/pull/3204#discussion_r2237911450
########## go/adbc/README.md: ########## @@ -0,0 +1,251 @@ +# adbc + +The adbc package provides: + +- Go Interfaces to [Arrow Database Connectivity](https://arrow.apache.org/adbc) (ADBC) for building ADBC drivers +- An ADBC Driver Manager package (`drivermgr`) for loading and using ADBC Drivers +- Scaffolding for writing new drivers in Go (`pkg`) + +See the [ADBC Website](https://arrow.apache.org/adbc/current/index.html) for more information on ADBC. + +## Getting Started + +To use ADBC with your database, you will need: + +1. An ADBC driver for your database +2. The ADBC `drivermgr` package to load and use the driver + +Below we show how to use the `drivermgr` package to load and use the SQLite ADBC Driver. +Not shown is how to make the SQLite ADBC driver available to the `drivermgr`. + +### Installation + +```sh +go get github.com/apache/arrow-adbc/go/adbc/drivermgr +``` + +### Creating a Connection + +```go +import ( + "context" + "github.com/apache/arrow-adbc/go/adbc" + "github.com/apache/arrow-adbc/go/adbc/drivermgr" +) + +ctx := context.Background() + +// Create driver and database +var drv drivermgr.Driver +db, err := drv.NewDatabase(map[string]string{ + "driver": "adbc_driver_sqlite", +}) +if err != nil { + return err +} +defer db.Close() + +// Open connection +conn, err := db.Open(ctx) +if err != nil { + return err +} +defer conn.Close() +``` + +In application code, both the database and connection must be closed after usage or +memory may leak. Use ``defer`` statements to ensure proper cleanup. + +### Creating a Statement + +```go +stmt, err := conn.NewStatement() +if err != nil { + return err +} +defer stmt.Close() Review Comment: Surprisingly, it's still the common convention of Go to just defer Close and ignore if it returns an error... -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org