2025-02-12 19:33:53 +03:00
|
|
|
---
|
|
|
|
sidebar_position: 1
|
|
|
|
---
|
|
|
|
|
|
|
|
import Tabs from '@theme/Tabs';
|
|
|
|
import TabItem from '@theme/TabItem';
|
|
|
|
|
|
|
|
# Create Connection
|
|
|
|
Creates a connection to the specified base
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-03-11 21:09:03 +03:00
|
|
|
`Function CreateConnection(Val ConnectionString = "", Val Tls = "") Export`
|
2025-02-12 19:33:53 +03:00
|
|
|
|
|
|
|
| Parameter | CLI option | Type | Required | Description |
|
|
|
|
|-|-|-|-|-|
|
|
|
|
| ConnectionString | - | String | ✖ | Connection string. See GenerateConnectionString |
|
2025-03-11 21:09:03 +03:00
|
|
|
| Tls | - | Structure Of KeyAndValue | ✖ | TLS settings, if necessary. See GetTlsSettings |
|
2025-02-12 19:33:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
Returns: Arbitrary - Connector object or structure with error information
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
|
|
:::caution
|
|
|
|
**NOCLI:** this method is not available in CLI version
|
|
|
|
:::
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```bsl title="1C:Enterprise/OneScript code example"
|
2025-02-17 17:16:27 +03:00
|
|
|
Address = "127.0.0.1";
|
2025-02-13 21:31:59 +03:00
|
|
|
Login = "bayselonarrend";
|
|
|
|
Password = "12we...";
|
|
|
|
Base = "postgres";
|
2025-02-12 19:33:53 +03:00
|
|
|
|
2025-02-13 21:31:59 +03:00
|
|
|
ConnectionString = OPI_PostgreSQL.GenerateConnectionString(Address, Base, Login, Password);
|
|
|
|
Result = OPI_PostgreSQL.CreateConnection(ConnectionString);
|
2025-02-14 15:29:42 +03:00
|
|
|
|
|
|
|
OPI_PostgreSQL.CloseConnection(Result);
|
2025-03-11 21:09:03 +03:00
|
|
|
|
|
|
|
// With TLS
|
|
|
|
|
|
|
|
Address = "api.athenaeum.digital";
|
|
|
|
Port = "5433";
|
|
|
|
|
|
|
|
ConnectionString = OPI_PostgreSQL.GenerateConnectionString(Address, Base, Login, Password, Port);
|
|
|
|
TLSSettings = OPI_PostgreSQL.GetTlsSettings(False);
|
|
|
|
|
|
|
|
Result = OPI_PostgreSQL.CreateConnection(ConnectionString, TLSSettings);
|
|
|
|
|
|
|
|
OPI_PostgreSQL.CloseConnection(Result);
|
2025-02-12 19:33:53 +03:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-18 14:08:09 +03:00
|
|
|
```json title="Result"
|
|
|
|
NOT JSON: AddIn.OPI_PostgreSQL.Main
|
|
|
|
```
|