2025-02-12 19:33:53 +03:00
---
sidebar_position: 1
2025-05-05 11:15:20 +03:00
description: Create Connection and other functions to work with PostgreSQL in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, PostgreSQL]
2025-02-12 19:33:53 +03:00
---
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-10-20 19:41:52 +03:00
Address = FunctionParameters["PG_IP"];
2025-02-13 21:31:59 +03:00
Login = "bayselonarrend";
2025-10-20 19:41:52 +03:00
Password = FunctionParameters["PG_Password"];
2025-02-13 21:31:59 +03:00
Base = "postgres";
2025-02-12 19:33:53 +03:00
2025-09-01 14:51:24 +03:00
TLS = True;
Port = 5432;
2025-03-11 21:09:03 +03:00
ConnectionString = OPI_PostgreSQL.GenerateConnectionString(Address, Base, Login, Password, Port);
2025-09-01 14:51:24 +03:00
If TLS Then
TLSSettings = OPI_PostgreSQL.GetTLSSettings(True);
Else
TLSSettings = Undefined;
EndIf;
2025-03-11 21:09:03 +03:00
2025-09-01 14:51:24 +03:00
Result = OPI_PostgreSQL.CreateConnection(ConnectionString, TLSSettings);
2025-02-12 19:33:53 +03:00
```
2025-06-17 16:20:59 +03:00
```json title="Result"
2025-09-12 20:23:31 +03:00
"AddIn.OPI_PostgreSQL.Main"
2025-06-17 16:20:59 +03:00
```