2025-03-27 20:05:59 +03:00
---
sidebar_position: 1
2025-05-05 11:15:20 +03:00
description: Create Connection and other functions to work with MySQL 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, MySQL]
2025-03-27 20:05:59 +03:00
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Create Connection
Creates a connection to the specified base
`Function CreateConnection(Val ConnectionString = "", Val Tls = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| ConnectionString | - | String | ✖ | Connection string. See GenerateConnectionString |
| Tls | - | Structure Of KeyAndValue | ✖ | TLS settings, if necessary. See GetTlsSettings |
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-06-27 11:47:43 +03:00
Address = FunctionParameters["PG_IP"];
2025-03-27 20:05:59 +03:00
Login = "bayselonarrend";
2025-06-27 11:47:43 +03:00
Password = FunctionParameters["PG_Password"];
2025-03-27 20:05:59 +03:00
Base = "";
ConnectionString = OPI_MySQL.GenerateConnectionString(Address, Base, Login, Password);
Result = OPI_MySQL.CreateConnection(ConnectionString);
OPI_MySQL.CloseConnection(Result);
2025-04-02 14:56:42 +03:00
// With TLS
2025-06-27 14:27:03 +03:00
Address = FunctionParameters["PG_IP"];
2025-04-02 14:56:42 +03:00
Port = "3307";
ConnectionString = OPI_MySQL.GenerateConnectionString(Address, Base, Login, Password, Port);
2025-06-27 14:27:03 +03:00
TLSSettings = OPI_MySQL.GetTlsSettings(True);
2025-04-02 14:56:42 +03:00
Result = OPI_MySQL.CreateConnection(ConnectionString, TLSSettings);
OPI_MySQL.CloseConnection(Result);
2025-03-27 20:05:59 +03:00
```
2025-04-06 17:14:16 +03:00
```json title="Result"
NOT JSON: AddIn.OPI_MySQL.Main
```