paleolimbot commented on code in PR #3176:
URL: https://github.com/apache/arrow-adbc/pull/3176#discussion_r2219548355


##########
docs/source/format/driver_manifests.rst:
##########
@@ -0,0 +1,351 @@
+.. Licensed to the Apache Software Foundation (ASF) under one
+.. or more contributor license agreements.  See the NOTICE file
+.. distributed with this work for additional information
+.. regarding copyright ownership.  The ASF licenses this file
+.. to you under the Apache License, Version 2.0 (the
+.. "License"); you may not use this file except in compliance
+.. with the License.  You may obtain a copy of the License at
+..
+..   http://www.apache.org/licenses/LICENSE-2.0
+..
+.. Unless required by applicable law or agreed to in writing,
+.. software distributed under the License is distributed on an
+.. "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+.. KIND, either express or implied.  See the License for the
+.. specific language governing permissions and limitations
+.. under the License.
+
+=================================
+ADBC Driver Manager and Manifests
+=================================
+
+.. note:: This document focuses on scenarios that utilize the driver manager
+          to load drivers.  The driver manager is not required to utilize ADBC
+          in general, but allows a convenient experience for dynamically
+          loading arbitrary drivers.
+
+The ADBC driver manager is itself, an ADBC driver which simply loads another 
driver
+dynamically and forwards the calls to the loaded driver.  For more information 
on the
+driver manager see :doc:`how_manager`.
+
+There are essentially two ways to specify a driver for the driver manager to 
load:
+
+1. Directly specifying the dynamic library to load
+2. Referring to a driver manifest file which contains metadata along with the
+   location of the dynamic library to be loaded
+
+When using the driver manager, you can either utilize the ``driver`` option to 
the
+driver manager, or you can use functions in the language bindings which 
explicitly
+load a driver by name.
+
+.. note:: In addition to the ``driver`` option, there is also an 
``entrypoint`` option
+          which can be used to specify the entrypoint function to call for 
populating
+          the driver function table.  If the driver does not use the default 
entrypoint
+          function, it can be indicated with this option.
+
+Directly Loading a Driver
+=========================
+
+The simplest mechanism for loading a driver via the driver manager is to 
provide a
+direct file path to the dynamic library as the driver name.
+
+.. tab-set::
+
+    .. tab-item:: C/C++
+       :sync: cpp
+
+        You can use the :c:func:`AdbcLoadDriver` function to load the driver 
directly.
+
+       .. code-block:: cpp
+
+          struct AdbcDriver driver;
+          struct AdbcError error;
+
+          std::memset(&driver, 0, sizeof(driver));
+          std::memset(&error, 0, sizeof(error));
+
+          auto status = AdbcLoadDriver("/path/to/libadbc_driver.so", nullptr,
+            ADBC_VERSION_1_1_0, &driver, &error);
+          // if status != ADBC_STATUS_OK then handle the error
+
+        Alternately, you can just use it as a driver via 
:c:struct:`AdbcDatabase`
+
+        .. code-block:: cpp
+
+           struct AdbcDatabase database;
+           struct AdbcError error;
+           std::memset(&database, 0, sizeof(database));
+           std::memset(&error, 0, sizeof(error));
+           auto status = AdbcDatabaseNew(&database, &error);
+           // check status
+           status = AdbcDatabaseSetOption(&database, "driver", 
"/path/to/libadbc_driver.so", &error);
+           // check status
+
+    .. tab-item:: GLib
+       :sync: glib
+
+        You can use it as a driver via ``GADBCDatabase`
+
+        .. code-block:: c
+           GError *error = NULL;
+           GADBCDatabase *database = gadbc_database_new(&error);
+           if (!database) {
+             /* handle error */
+           }
+           if (!gadbc_database_set_option(database, "driver", 
"/path/to/libadbc_driver.so", &error)) {
+             /* handle error */
+           }
+
+    .. tab-item:: Go
+       :sync: go
+
+       Loading a driver in Go is similar:
+
+       .. 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": "/path/to/libadbc_driver.so",
+            })
+            if err != nil {
+              // handle error
+            }
+            defer db.Close()
+
+            // ... do stuff
+          }
+
+    .. tab-item:: Python
+       :sync: python
+
+       You can use the ``DBAPI`` interface as follows:
+
+       .. code-block:: python
+
+          import adbc_driver_manager
+
+          with 
adbc_driver_manager.dbapi.connect(driver="/path/to/libadbc_driver.so") as conn:
+              # use the connection
+              pass
+

Review Comment:
   ```suggestion
       .. tab-item:: R
          :sync: r
          You can use the ``adbcdrivermanager`` interface as follows:
   
          .. code-block:: r
             library(adbcdrivermanager)
             con <- adbc_driver("/path/to/libadbc_driver.so") |>
               adbc_database_init(uri = "...") |>
               adbc_connection_init()
   
   ```



-- 
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

Reply via email to