Skip to content

Commit 408285c

Browse files
authored
Merge 25a1b3e into f5e2b02
2 parents f5e2b02 + 25a1b3e commit 408285c

File tree

2 files changed

+38
-24
lines changed

2 files changed

+38
-24
lines changed

ydb/docs/en/core/postgresql/import.md

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Dump data form PostgreSQL
22

3+
{% include [./_includes/alert.md](./_includes/alert_preview.md) %}
4+
35
Data from PostgreSQL can be migrated to {{ ydb-short-name }} using utilities such as [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html), [psql](https://www.postgresql.org/docs/current/app-psql.html), and [{{ ydb-short-name }} CLI](../reference/ydb-cli/index.md). The [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and [psql](https://www.postgresql.org/docs/current/app-psql.html) utilities are installed with PostgreSQL. [{{ ydb-short-name }} CLI](../reference/ydb-cli/index.md) is {{ ydb-short-name }}'s command-line client, which is [installed separately](../reference/ydb-cli/install.md).
46

57
To do this, you need to:
@@ -26,8 +28,8 @@ The `ydb tools pg-convert` command reads a dump file or standard input created b
2628
* Deleting the `WITH (...)` section in `CREATE TABLE`.
2729
* Commenting out unsupported constructs (optionally):
2830

29-
* `SELECT pg_catalog.set_config.*`
30-
* `ALTER TABLE`
31+
* `SELECT pg_catalog.set_config.*`
32+
* `ALTER TABLE`
3133

3234
If the CLI cannot find a table's primary key, it will automatically create a [BIGSERIAL](https://www.postgresql.org/docs/current/datatype-numeric.html#DATATYPE-SERIAL) column named `__ydb_stub_id` as the primary key.
3335

@@ -60,26 +62,31 @@ As an example, data generated by [pgbench](https://www.postgresql.org/docs/curre
6062

6163
1. Start Docker containers with PostgreSQL and {{ ydb-short-name }}:
6264

63-
```bash
64-
docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
65-
-e POSTGRES_DB=local --name postgres postgres:14
66-
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
67-
-e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
68-
-e YDB_FEATURE_FLAGS=enable_temp_tables \
69-
-e YDB_USE_IN_MEMORY_PDISKS=true \
70-
ghcr.io/ydb-platform/ydb-local:latest
71-
```
65+
```bash
66+
docker run -d --rm -e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
67+
-e POSTGRES_DB=local --name postgres postgres:14
68+
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
69+
-e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
70+
-e YDB_FEATURE_FLAGS=enable_temp_tables,enable_table_pg_types \
71+
-e YDB_USE_IN_MEMORY_PDISKS=true \
72+
ghcr.io/ydb-platform/local-ydb:latest
73+
```
7274

7375
2. Generate data through [pgbench](https://www.postgresql.org/docs/current/pgbench.html):
7476

75-
```bash
76-
docker exec postgres pgbench -i postgres://root:1234@localhost/local
77-
```
77+
```bash
78+
docker exec postgres pgbench postgres://root:1234@localhost/local -i
79+
```
80+
81+
3. Create a dump of the database using [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html):
82+
83+
```bash
84+
docker exec postgres pg_dump postgres://root:1234@localhost/local --inserts \
85+
--column-inserts --encoding=utf_8 --rows-per-insert=1000 > dump.sql
86+
```
7887

79-
3. Create a dump of the database using [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) and load it into {{ ydb-short-name }}:
88+
4. Load the dump into {{ ydb-short-name }}:
8089

81-
```bash
82-
docker exec postgres pg_dump -U root --format=c --file=/var/lib/postgresql/data/dump.sql local
83-
docker cp postgres:/var/lib/postgresql/data/dump.sql .
84-
cat dump.sql | docker exec -i ydb-postgres psql -U root -d local
85-
```
90+
```bash
91+
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://root:1234@localhost/local
92+
```

ydb/docs/ru/core/postgresql/import.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Импорт данных из PostgreSQL
22

3+
{% include [./_includes/alert.md](./_includes/alert_preview.md) %}
4+
35
Данные из PostgreSQL в {{ ydb-name }} можно импортировать различными способами:
46

57
- С помощью [pg-dump](#pg-dump).
@@ -82,9 +84,9 @@
8284
-e POSTGRES_DB=local --name postgres postgres:14
8385
docker run --name ydb-postgres -d --pull always -p 5432:5432 -p 8765:8765 \
8486
-e POSTGRES_USER=root -e POSTGRES_PASSWORD=1234 \
85-
-e YDB_FEATURE_FLAGS=enable_temp_tables \
87+
-e YDB_FEATURE_FLAGS=enable_temp_tables,enable_table_pg_types \
8688
-e YDB_USE_IN_MEMORY_PDISKS=true \
87-
ghcr.io/ydb-platform/local-ydb:nightly
89+
ghcr.io/ydb-platform/local-ydb:latest
8890
```
8991

9092
2. Сгенерировать данные через [pgbench](https://www.postgresql.org/docs/current/pgbench.html):
@@ -93,10 +95,15 @@
9395
docker exec postgres pgbench postgres://root:1234@localhost/local -i
9496
```
9597

96-
3. Сделать дамп базы через [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html) и загрузить его в {{ ydb-short-name }}:
98+
3. Сделать дамп базы через [pg_dump](https://www.postgresql.org/docs/current/app-pgdump.html):
9799

98100
```bash
99101
docker exec postgres pg_dump postgres://root:1234@localhost/local --inserts \
100102
--column-inserts --encoding=utf_8 --rows-per-insert=1000 > dump.sql
101-
ydb tools pg-convert -i dump.sql | psql postgresql://root:1234@localhost/local
102103
```
104+
105+
4. Загрузить дамп базы в {{ ydb-short-name }}:
106+
107+
```bash
108+
ydb tools pg-convert --ignore-unsupported -i dump.sql | psql postgresql://root:1234@localhost/local
109+
```

0 commit comments

Comments
 (0)