You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by li...@apache.org on 2023/06/20 20:47:57 UTC
[arrow-adbc] branch main updated: docs(go): Add Go install and usage examples (#826)
This is an automated email from the ASF dual-hosted git repository.
lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git
The following commit(s) were added to refs/heads/main by this push:
new 3112909c docs(go): Add Go install and usage examples (#826)
3112909c is described below
commit 3112909c131f4bd304b8237a73093f7d6496fcd3
Author: Matt Topol <zo...@gmail.com>
AuthorDate: Tue Jun 20 16:47:53 2023 -0400
docs(go): Add Go install and usage examples (#826)
---
docs/source/driver/flight_sql.rst | 39 +++++++++++++++++++++++++++++++++-
docs/source/driver/postgresql.rst | 36 +++++++++++++++++++++++++++++++-
docs/source/driver/snowflake.rst | 28 +++++++++++++++++++++++++
docs/source/driver/sqlite.rst | 44 +++++++++++++++++++++++++++++++++++++++
4 files changed, 145 insertions(+), 2 deletions(-)
diff --git a/docs/source/driver/flight_sql.rst b/docs/source/driver/flight_sql.rst
index 0e9f227d..f0f7363a 100644
--- a/docs/source/driver/flight_sql.rst
+++ b/docs/source/driver/flight_sql.rst
@@ -43,7 +43,7 @@ Installation
.. code-block:: shell
- go get github.com/apache/arrow-adbc/go
+ go get github.com/apache/arrow-adbc/go/adbc
.. tab-item:: Java
:sync: java
@@ -115,6 +115,43 @@ the :cpp:class:`AdbcDatabase`.
) as conn:
pass
+ .. tab-item:: Go
+ :sync: go
+
+ .. code-block:: go
+
+ import (
+ "context"
+
+ "github.com/apache/arrow-adbc/go/adbc"
+ "github.com/apache/arrow-adbc/go/adbc/driver/flightsql"
+ )
+
+ var headers = map[string]string{"foo": "bar"}
+
+ func main() {
+ options := map[string]string{
+ adbc.OptionKeyURI: "grpc+tls://localhost:8080",
+ flightsql.OptionSSLSkipVerify: adbc.OptionValueEnabled,
+ }
+
+ for k, v := range headers {
+ options[flightsql.OptionRPCCallHeaderPrefix + k] = v
+ }
+
+ var drv flightsql.Driver
+ db, err := drv.NewDatabase(options)
+ if err != nil {
+ // do something with the error
+ }
+
+ cnxn, err := db.Open(context.Background())
+ if err != nil {
+ // handle the error
+ }
+ defer cnxn.Close()
+ }
+
Supported Features
==================
diff --git a/docs/source/driver/postgresql.rst b/docs/source/driver/postgresql.rst
index b8e43db2..762ce678 100644
--- a/docs/source/driver/postgresql.rst
+++ b/docs/source/driver/postgresql.rst
@@ -53,10 +53,11 @@ Installation
:sync: go
Install the C/C++ package and use the Go driver manager.
+ Requires CGO.
.. code-block:: shell
- go get github.com/apache/arrow-adbc/go
+ go get github.com/apache/arrow-adbc/go/adbc/drivermgr
.. tab-item:: Python
:sync: python
@@ -124,6 +125,39 @@ the :cpp:class:`AdbcDatabase`. This should be a `connection URI
db <- adbc_database_init(adbcpostgresql::adbcpostgresql(), uri = uri)
con <- adbc_connection_init(db)
+ .. tab-item:: Go
+ :sync: go
+
+ You must have `libadbc_driver_postgresql.so` on your LD_LIBRARY_PATH,
+ or in the same directory as the executable when you run this. This
+ requires CGO and loads the C++ ADBC postgresql driver.
+
+ .. code-block:: go
+
+ import (
+ "context"
+
+ "github.com/apache/arrow-adbc/go/adbc"
+ "github.com/apache/arrow-adbc/go/adbc/drivermgr"
+ )
+
+ func main() {
+ var drv drivermgr.Driver
+ db, err := drv.NewDatabase(map[string]string{
+ "driver": "adbc_driver_postgresql",
+ adbc.OptionKeyURI: "postgresql://user:pass@localhost:5433/postgres",
+ })
+ if err != nil {
+ // handle error
+ }
+
+ cnxn, err := db.Open(context.Background())
+ if err != nil {
+ // handle error
+ }
+ defer cnxn.Close()
+ }
+
Supported Features
==================
diff --git a/docs/source/driver/snowflake.rst b/docs/source/driver/snowflake.rst
index 273818db..72581d26 100644
--- a/docs/source/driver/snowflake.rst
+++ b/docs/source/driver/snowflake.rst
@@ -108,6 +108,34 @@ constructing the :cpp::class:`AdbcDatabase`.
db <- adbc_database_init(adbcsnowflake::adbcsnowflake(), uri = uri)
con <- adbc_connection_init(db)
+ .. tab-item:: Go
+ :sync: go
+
+ .. code-block:: go
+
+ import (
+ "context"
+
+ "github.com/apache/arrow-adbc/go/adbc"
+ "github.com/apache/arrow-adbc/go/adbc/driver/snowflake"
+ )
+
+ func main() {
+ var drv snowflake.Driver
+ db, err := drv.NewDatabase(map[string]string{
+ adbc.OptionKeyURI: "<snowflake uri>",
+ })
+ if err != nil {
+ // handle error
+ }
+
+ cnxn, err := db.Open(context.Background())
+ if err != nil {
+ // handle error
+ }
+ defer cnxn.Close()
+ }
+
URI Format
----------
diff --git a/docs/source/driver/sqlite.rst b/docs/source/driver/sqlite.rst
index 4693b7d1..00be9922 100644
--- a/docs/source/driver/sqlite.rst
+++ b/docs/source/driver/sqlite.rst
@@ -61,6 +61,17 @@ Installation
remotes::install_github("apache/arrow-adbc/r/adbcdrivermanager", build = FALSE)
remotes::install_github("apache/arrow-adbc/r/adbcsqlite", build = FALSE)
+ .. tab-item:: Go
+ :sync: go
+
+ Install the C/C++ package and use the Go driver manager.
+ Requires CGO.
+
+ .. code-block:: shell
+
+ go get github.com/apache/arrow-adbc/go/adbc/drivermgr
+
+
Usage
=====
@@ -107,6 +118,39 @@ shared across all connections.
db <- adbc_database_init(adbcsqlite::adbcsqlite(), uri = ":memory:")
con <- adbc_connection_init(db)
+ .. tab-item:: Go
+ :sync: go
+
+ You must have `libadbc_driver_sqlite.so` on your LD_LIBRARY_PATH,
+ or in the same directory as the executable when you run this. This
+ requires CGO and loads the C++ ADBC sqlite driver.
+
+ .. code-block:: go
+
+ import (
+ "context"
+
+ "github.com/apache/arrow-adbc/go/adbc"
+ "github.com/apache/arrow-adbc/go/adbc/drivermgr"
+ )
+
+ func main() {
+ var drv drivermgr.Driver
+ db, err := drv.NewDatabase(map[string]string{
+ "driver": "adbc_driver_sqlite",
+ adbc.OptionKeyURI: "<sqlite uri>",
+ })
+ if err != nil {
+ // handle error
+ }
+
+ cnxn, err := db.Open(context.Background())
+ if err != nil {
+ // handle error
+ }
+ defer cnxn.Close()
+ }
+
Supported Features
==================