|
15 | 15 | .. specific language governing permissions and limitations |
16 | 16 | .. under the License. |
17 | 17 |
|
18 | | -================================== |
19 | | -Driver Manager Connection Profiles |
20 | | -================================== |
| 18 | +=========================================== |
| 19 | +ADBC Driver Manager and Connection Profiles |
| 20 | +=========================================== |
21 | 21 |
|
22 | | -Overview |
23 | | -======== |
| 22 | +.. note:: This document describes using the :term:`driver manager` to load |
| 23 | + drivers. The driver manager is not required to use ADBC in general |
| 24 | + but it allows loading drivers written in a different language from the |
| 25 | + application and improves the experience when using multiple drivers in |
| 26 | + a single application. For more information on how the driver manager |
| 27 | + works see :doc:`how_manager`. |
24 | 28 |
|
25 | | -There are two ways to pass connection options to driver managers: |
| 29 | +There are two ways to pass driver options through the driver manager: |
26 | 30 |
|
27 | | -1. Directly specifying all connection options as arguments to driver manager functions in your |
28 | | - application code. (see the `SetOption` family of functions in :doc:`specification` for details) |
29 | | -2. Referring to a **connection profile** which contains connection options, and optionally overriding |
30 | | - some options in your application code. |
| 31 | +1. Directly specifying all options as arguments to the driver manager in your |
| 32 | + application code (see the `SetOption` family of functions in |
| 33 | + :doc:`specification` for details). |
| 34 | +2. Referring to a :term:`connection profile` which contains options, and |
| 35 | + optionally overriding some options by setting them through the above |
| 36 | + method. |
31 | 37 |
|
32 | | -The ADBC driver manager supports **connection profiles** that specify a driver and connection options |
33 | | -in a reusable configuration. This allows users to: |
| 38 | +Connection profiles combine a driver and driver options in a reusable |
| 39 | +configuration. This allows users to: |
34 | 40 |
|
35 | 41 | - Define connection information in files or environment variables |
36 | 42 | - Share connection configurations across applications |
37 | 43 | - Distribute standardized connection settings |
38 | 44 | - Avoid hardcoding driver names and credentials in application code |
39 | 45 |
|
40 | | -Profiles are loaded during ``AdbcDatabaseInit()`` before initializing the driver. Options |
41 | | -from the profile are applied automatically but do not override options already set via ``AdbcDatabaseSetOption()``. |
| 46 | +Profiles are loaded during ``AdbcDatabaseInit()`` before initializing the |
| 47 | +driver. Options from the profile are applied automatically but do not override |
| 48 | +options already set via ``AdbcDatabaseSetOption()``. |
42 | 49 |
|
43 | 50 | Quick Start |
44 | 51 | =========== |
@@ -74,9 +81,12 @@ Filesystem-based profiles use TOML format with the following structure: |
74 | 81 |
|
75 | 82 | .. code-block:: toml |
76 | 83 |
|
| 84 | + # The version is required. |
77 | 85 | profile_version = 1 |
| 86 | + # It is optional to provide the driver. |
78 | 87 | driver = "snowflake" |
79 | 88 |
|
| 89 | + # The Options table is required, even if empty |
80 | 90 | [Options] |
81 | 91 | # String options |
82 | 92 | adbc.snowflake.sql.account = "mycompany" |
@@ -111,18 +121,19 @@ driver |
111 | 121 |
|
112 | 122 | The ``driver`` field specifies which ADBC driver to load. This can be: |
113 | 123 |
|
114 | | -- A driver name (e.g., ``"snowflake"``) |
| 124 | +- A driver or driver manifest name (e.g., ``"snowflake"``) |
115 | 125 | - A path to a shared library (e.g., ``"/usr/local/lib/libadbc_driver_snowflake.so"``) |
116 | 126 | - A path to a driver manifest (e.g., ``"/etc/adbc/drivers/snowflake.toml"``) |
117 | 127 |
|
118 | 128 | If omitted, the driver must be specified through other means (e.g., the ``driver`` option or ``uri`` parameter). |
| 129 | +If the application specifies a driver, and specifies a profile that itself references a driver, the two must match exactly, or it is an error. |
119 | 130 | The driver will be loaded identically to if it was specified via ``AdbcDatabaseSetOption("driver", "<driver>")``. |
120 | 131 | For more detils, see :doc:`driver_manifests`. |
121 | 132 |
|
122 | 133 | Options Section |
123 | 134 | --------------- |
124 | 135 |
|
125 | | -The ``[Options]`` section contains driver-specific configuration options. Options can be of the following types: |
| 136 | +The ``[Options]`` section contains driver-specific configuration options. This section must be present, even if empty. Options can be of the following types: |
126 | 137 |
|
127 | 138 | **String values** |
128 | 139 | Applied using ``AdbcDatabaseSetOption()`` |
@@ -153,6 +164,10 @@ The ``[Options]`` section contains driver-specific configuration options. Option |
153 | 164 |
|
154 | 165 | adbc.snowflake.sql.client_session_keep_alive = true |
155 | 166 |
|
| 167 | +.. warning:: If the application overrides option values but uses a different |
| 168 | + type for the value than the profile does, it is undefined which |
| 169 | + will take effect. |
| 170 | + |
156 | 171 | Value Substitution |
157 | 172 | ------------------ |
158 | 173 |
|
@@ -190,7 +205,7 @@ Profile Search Locations |
190 | 205 |
|
191 | 206 | When using a profile name (not an absolute path), the driver manager searches for ``<profile_name>.toml`` in the following locations: |
192 | 207 |
|
193 | | -1. **Additional Search Paths** (if configured via ``AdbcDriverManagerDatabaseSetAdditionalSearchPathList()``) |
| 208 | +1. **Additional Search Paths** (if configured via ``additional_profile_search_path_list`` option) |
194 | 209 | 2. **ADBC_PROFILE_PATH** environment variable (colon-separated on Unix, semicolon-separated on Windows) |
195 | 210 | 3. **Conda Environment** (if built with Conda support and ``CONDA_PREFIX`` is set): |
196 | 211 |
|
@@ -561,34 +576,28 @@ Sets a custom connection profile provider. Must be called before ``AdbcDatabaseI |
561 | 576 | Setting Additional Search Paths |
562 | 577 | -------------------------------- |
563 | 578 |
|
564 | | -.. code-block:: c |
565 | | -
|
566 | | - AdbcStatusCode AdbcDriverManagerDatabaseSetAdditionalSearchPathList( |
567 | | - struct AdbcDatabase* database, |
568 | | - const char* path_list, |
569 | | - struct AdbcError* error); |
570 | | -
|
571 | | -Adds additional directories to search for profiles. Must be called before ``AdbcDatabaseInit()``. |
572 | | - |
573 | | -**Parameters:** |
574 | | - |
575 | | -- ``database``: Database object to configure |
576 | | -- ``path_list``: OS-specific path separator delimited list (``:``) on Unix, ``;`` on Windows), or ``NULL`` to clear |
577 | | -- ``error``: Optional error output |
578 | | - |
579 | | -**Returns:** ``ADBC_STATUS_OK`` on success, error code otherwise. |
| 579 | +This can be done via the ``additional_profile_search_path_list`` option. It |
| 580 | +must be set before ``AdbcDatabaseInit()``. The value of this option is an |
| 581 | +OS-specific delimited list (``:`` on Unix, ``;`` on Windows), or ``NULL`` to |
| 582 | +clear. |
580 | 583 |
|
581 | 584 | **Example:** |
582 | 585 |
|
583 | 586 | .. code-block:: c |
584 | 587 |
|
585 | 588 | // Unix/Linux/macOS |
586 | | - AdbcDriverManagerDatabaseSetAdditionalSearchPathList( |
587 | | - &database, "/opt/app/profiles:/etc/app/profiles", &error); |
| 589 | + AdbcDatabaseSetOption( |
| 590 | + &database, |
| 591 | + "additional_profile_search_path_list", |
| 592 | + "/opt/app/profiles:/etc/app/profiles", |
| 593 | + &error); |
588 | 594 |
|
589 | 595 | // Windows |
590 | | - AdbcDriverManagerDatabaseSetAdditionalSearchPathList( |
591 | | - &database, "C:\\App\\Profiles;C:\\ProgramData\\App\\Profiles", &error); |
| 596 | + AdbcDatabaseSetOption( |
| 597 | + &database, |
| 598 | + "additional_profile_search_path_list", |
| 599 | + "C:\\App\\Profiles;C:\\ProgramData\\App\\Profiles", |
| 600 | + &error); |
592 | 601 |
|
593 | 602 |
|
594 | 603 | See Also |
|
0 commit comments