pgpack-dumper 0.3.0.0__cp314-cp314-macosx_11_0_arm64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pgpack_dumper/__init__.py +46 -0
- pgpack_dumper/common/__init__.py +58 -0
- pgpack_dumper/common/columns.py +30 -0
- pgpack_dumper/common/connector.py +11 -0
- pgpack_dumper/common/copy.py +157 -0
- pgpack_dumper/common/diagram.py +78 -0
- pgpack_dumper/common/errors.py +26 -0
- pgpack_dumper/common/logger.py +70 -0
- pgpack_dumper/common/metadata.py +38 -0
- pgpack_dumper/common/query.py +62 -0
- pgpack_dumper/common/queryes/attributes.sql +4 -0
- pgpack_dumper/common/queryes/copy_from.sql +1 -0
- pgpack_dumper/common/queryes/copy_to.sql +1 -0
- pgpack_dumper/common/queryes/dbname.sql +2 -0
- pgpack_dumper/common/queryes/gpversion.sql +1 -0
- pgpack_dumper/common/queryes/prepare.sql +4 -0
- pgpack_dumper/common/queryes/relkind.sql +1 -0
- pgpack_dumper/common/reader.cpython-314-darwin.so +0 -0
- pgpack_dumper/common/reader.pxd +11 -0
- pgpack_dumper/common/reader.pyi +35 -0
- pgpack_dumper/common/reader.pyx +67 -0
- pgpack_dumper/common/stream.py +80 -0
- pgpack_dumper/common/structs.py +34 -0
- pgpack_dumper/dumper.py +460 -0
- pgpack_dumper/version.py +1 -0
- pgpack_dumper-0.3.0.0.dist-info/METADATA +201 -0
- pgpack_dumper-0.3.0.0.dist-info/RECORD +30 -0
- pgpack_dumper-0.3.0.0.dist-info/WHEEL +6 -0
- pgpack_dumper-0.3.0.0.dist-info/licenses/LICENSE +21 -0
- pgpack_dumper-0.3.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,201 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: pgpack_dumper
|
3
|
+
Version: 0.3.0.0
|
4
|
+
Summary: Library for read and write PGPack format between PostgreSQL and file.
|
5
|
+
Author-email: 0xMihalich <bayanmobile87@gmail.com>
|
6
|
+
Project-URL: Homepage, https://github.com/0xMihalich/pgpack_dumper
|
7
|
+
Project-URL: Documentation, https://github.com/0xMihalich/pgpack_dumper#readme
|
8
|
+
Project-URL: Repository, https://github.com/0xMihalich/pgpack_dumper
|
9
|
+
Project-URL: Changelog, https://github.com/0xMihalich/pgpack_dumper/blob/main/CHANGELOG.md
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
11
|
+
Classifier: Intended Audience :: Developers
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
17
|
+
Requires-Python: >=3.10
|
18
|
+
Description-Content-Type: text/markdown
|
19
|
+
License-File: LICENSE
|
20
|
+
Requires-Dist: pgpack==0.3.0.9
|
21
|
+
Requires-Dist: psycopg_binary>=3.2.11
|
22
|
+
Requires-Dist: psycopg>=3.2.11
|
23
|
+
Requires-Dist: sqlparse>=0.5.3
|
24
|
+
Dynamic: license-file
|
25
|
+
|
26
|
+
# PGPackDumper
|
27
|
+
|
28
|
+
Library for read and write PGPack format between PostgreSQL and file
|
29
|
+
|
30
|
+
## Examples
|
31
|
+
|
32
|
+
### Initialization
|
33
|
+
|
34
|
+
```python
|
35
|
+
from pgpack_dumper import (
|
36
|
+
CompressionMethod,
|
37
|
+
PGConnector,
|
38
|
+
PGPackDumper,
|
39
|
+
)
|
40
|
+
|
41
|
+
connector = PGConnector(
|
42
|
+
host = <your host>,
|
43
|
+
dbname = <your database>,
|
44
|
+
user = <your username>,
|
45
|
+
password = <your password>,
|
46
|
+
port = <your port>,
|
47
|
+
)
|
48
|
+
|
49
|
+
dumper = PGPackDumper(
|
50
|
+
connector=connector,
|
51
|
+
compression_method=CompressionMethod.ZSTD, # or CompressionMethod.LZ4 or CompressionMethod.NONE
|
52
|
+
)
|
53
|
+
```
|
54
|
+
|
55
|
+
### Read dump from PostgreSQL into file
|
56
|
+
|
57
|
+
```python
|
58
|
+
file_name = "test_table.pgpack"
|
59
|
+
# you need define one of parameter query or table_name
|
60
|
+
query = "select ..." # some sql query
|
61
|
+
table_name = "public.test_table" # or some table
|
62
|
+
|
63
|
+
with open(file_name, "wb") as fileobj:
|
64
|
+
dumper.read_dump(
|
65
|
+
fileobj,
|
66
|
+
query,
|
67
|
+
table_name,
|
68
|
+
)
|
69
|
+
```
|
70
|
+
|
71
|
+
### Write dump from file into PostgreSQL
|
72
|
+
|
73
|
+
```python
|
74
|
+
file_name = "test_table.pgpack"
|
75
|
+
# you need define one of parameter table_name
|
76
|
+
table_name = "public.test_table" # some table
|
77
|
+
|
78
|
+
with open(file_name, "rb") as fileobj:
|
79
|
+
dumper.write_dump(
|
80
|
+
fileobj,
|
81
|
+
table_name,
|
82
|
+
)
|
83
|
+
```
|
84
|
+
|
85
|
+
### Write from PostgreSQL into PostgreSQL
|
86
|
+
|
87
|
+
Same server
|
88
|
+
|
89
|
+
```python
|
90
|
+
|
91
|
+
table_dest = "public.test_table_write" # some table for write
|
92
|
+
table_src = "public.test_table_read" # some table for read
|
93
|
+
query_src = "select ..." # or some sql query for read
|
94
|
+
|
95
|
+
dumper.write_between(
|
96
|
+
table_dest,
|
97
|
+
table_src,
|
98
|
+
query_src,
|
99
|
+
)
|
100
|
+
```
|
101
|
+
|
102
|
+
Different servers
|
103
|
+
|
104
|
+
```python
|
105
|
+
|
106
|
+
connector_src = PGConnector(
|
107
|
+
host = <host src>,
|
108
|
+
dbname = <database src>,
|
109
|
+
user = <username src>,
|
110
|
+
password = <password src>,
|
111
|
+
port = <port src>,
|
112
|
+
)
|
113
|
+
|
114
|
+
dumper_src = PGPackDumper(connector=connector_src)
|
115
|
+
|
116
|
+
table_dest = "public.test_table_write" # some table for write
|
117
|
+
table_src = "public.test_table_read" # some table for read
|
118
|
+
query_src = "select ..." # or some sql query for read
|
119
|
+
|
120
|
+
dumper.write_between(
|
121
|
+
table_dest,
|
122
|
+
table_src,
|
123
|
+
query_src,
|
124
|
+
dumper_src,
|
125
|
+
)
|
126
|
+
```
|
127
|
+
|
128
|
+
### Get stream object
|
129
|
+
|
130
|
+
```python
|
131
|
+
# you need define one of parameter query or table_name
|
132
|
+
query = "select ..." # some sql query
|
133
|
+
table_name = "public.test_table" # or some table
|
134
|
+
reader = dumper.to_reader(query=query, table_name=table_name)
|
135
|
+
print(reader)
|
136
|
+
# <PostgreSQL/GreenPlum stream reader>
|
137
|
+
# ┌─────────────────┬─────────────────┐
|
138
|
+
# │ Column Name │ PostgreSQL Type │
|
139
|
+
# ╞═════════════════╪═════════════════╡
|
140
|
+
# │ column1 │ date │
|
141
|
+
# │-----------------+-----------------│
|
142
|
+
# │ column2 │ bpchar │
|
143
|
+
# │-----------------+-----------------│
|
144
|
+
# │ column3 │ bpchar │
|
145
|
+
# └─────────────────┴─────────────────┘
|
146
|
+
# Total columns: 3
|
147
|
+
# Readed rows: 0
|
148
|
+
```
|
149
|
+
|
150
|
+
StreamReader has three methods available,
|
151
|
+
but only one of the methods is available at a time within a single session.
|
152
|
+
|
153
|
+
```python
|
154
|
+
# read as python generator object
|
155
|
+
reader.to_rows()
|
156
|
+
# or read as pandas.DataFrame
|
157
|
+
reader.to_pandas()
|
158
|
+
# or read as polars.DataFrame
|
159
|
+
reader.to_polars()
|
160
|
+
```
|
161
|
+
|
162
|
+
### Write from python objects into target table
|
163
|
+
|
164
|
+
```python
|
165
|
+
# some table for write data
|
166
|
+
table_name = "public.test_table"
|
167
|
+
dtype_data: Itarable[Any]
|
168
|
+
pandas_frame: pandas.DataFrame
|
169
|
+
polars_frame: polars.DataFrame
|
170
|
+
|
171
|
+
# write from python object
|
172
|
+
dumper.from_rows(dtype_data, table_name)
|
173
|
+
# write from pandas.DataFrame
|
174
|
+
dumper.from_pandas(pandas_frame, table_name)
|
175
|
+
# write from polars.DataFrame
|
176
|
+
dumper.from_polars(polars_frame, table_name)
|
177
|
+
```
|
178
|
+
|
179
|
+
### Open PGPack file format
|
180
|
+
|
181
|
+
Get info from my another repository https://github.com/0xMihalich/pgpack
|
182
|
+
|
183
|
+
## Installation
|
184
|
+
|
185
|
+
### From pip
|
186
|
+
|
187
|
+
```bash
|
188
|
+
pip install pgpack-dumper
|
189
|
+
```
|
190
|
+
|
191
|
+
### From local directory
|
192
|
+
|
193
|
+
```bash
|
194
|
+
pip install .
|
195
|
+
```
|
196
|
+
|
197
|
+
### From git
|
198
|
+
|
199
|
+
```bash
|
200
|
+
pip install git+https://github.com/0xMihalich/pgpack_dumper
|
201
|
+
```
|
@@ -0,0 +1,30 @@
|
|
1
|
+
pgpack_dumper-0.3.0.0.dist-info/RECORD,,
|
2
|
+
pgpack_dumper-0.3.0.0.dist-info/WHEEL,sha256=2Id6qreet5t4wZv58bZfijJ58qrc2xkw6OVvWfeqxV0,136
|
3
|
+
pgpack_dumper-0.3.0.0.dist-info/top_level.txt,sha256=AhxLKWTyGtJWNLWUSyBu54xY4wjVS8vSXgW4wwq4bYk,14
|
4
|
+
pgpack_dumper-0.3.0.0.dist-info/METADATA,sha256=m8GpfNmtDaxEgZW-imd67SfDs_LXTlOsL6ZBuvuJe6s,5069
|
5
|
+
pgpack_dumper-0.3.0.0.dist-info/licenses/LICENSE,sha256=9IYMxtPlcVkrfjeRPA9GRUmaQkLG_FL-Gx7HxLvcLDQ,1067
|
6
|
+
pgpack_dumper/version.py,sha256=QjDEkJ4u3QAQZ3CwLE5X_wJEerb9U3SSlJbnhJdcrxg,24
|
7
|
+
pgpack_dumper/__init__.py,sha256=2x9LRaKPMjMuOoP9pBAeSRZoAeCo9B8fxFbnW_N7kh8,966
|
8
|
+
pgpack_dumper/dumper.py,sha256=5WnXg69hszHjzPXRoAMAvFY5ZrVsKVtx48XMsLDG0og,14261
|
9
|
+
pgpack_dumper/common/metadata.py,sha256=Z_vbgi1V85jgPR0h1xbUtt3Ru7vMcmG06bd13Gn_ocY,864
|
10
|
+
pgpack_dumper/common/diagram.py,sha256=2w5-s5qwYjCd0cqqlBRbHQ8E90jU7Ay7TNLeROHjCa0,2505
|
11
|
+
pgpack_dumper/common/query.py,sha256=5kMXFJvBWCKW3hYfqsI7F1qc1I786IPNGIhMXypIv1E,1359
|
12
|
+
pgpack_dumper/common/reader.pyx,sha256=vRIR558enMtx4gueWtoujJbpRoWbKnLWx_foVR-rxIw,1821
|
13
|
+
pgpack_dumper/common/__init__.py,sha256=gz-xk9TgMHVx5hlFnipO3kuLp7k3grb-OhoSP5Y7LvU,1242
|
14
|
+
pgpack_dumper/common/copy.py,sha256=3mzGGVOVMdnUXqmpdXu3THQJpJB85D9LQN-MC-LX-fg,4941
|
15
|
+
pgpack_dumper/common/logger.py,sha256=gsFCOjnCU3Hvg5UGYMVrPjKRCZKRFtBFBX-7QLZshFo,1675
|
16
|
+
pgpack_dumper/common/stream.py,sha256=PXWcxmDmuK7ueI3MTUfQnmXKWz3A99W-knNRvq_-ZG0,2245
|
17
|
+
pgpack_dumper/common/columns.py,sha256=Pa8bzhoi8tXbm3GlgVeHYM3auPORD41q-L29JF_pRqM,693
|
18
|
+
pgpack_dumper/common/structs.py,sha256=gS7vT-_yZ6R45j212B0kYKCJgHalxkdEN84Itctv7Ok,1033
|
19
|
+
pgpack_dumper/common/connector.py,sha256=WGBovyXWxgeseGXploUW0L_4R0GQBtuInl89zqvbKLY,176
|
20
|
+
pgpack_dumper/common/reader.pxd,sha256=flQddQni7UgYU_XPGpnILc7GVDFYjRgq-tbKRTUPbE8,252
|
21
|
+
pgpack_dumper/common/reader.pyi,sha256=UoW-mEAw_G7TLBbIoPTJwpdtucv5IygHdkHc_ZcVM5Y,675
|
22
|
+
pgpack_dumper/common/errors.py,sha256=1WIe9PUq5-Q6VNWyWAaXWr7xuXS2ixJCUB5sDOi5Xgs,591
|
23
|
+
pgpack_dumper/common/reader.cpython-314-darwin.so,sha256=D4MiEQQkIkHFJZnXnf9OfVzk7PiAdnOG-9fja1XwFO8,115872
|
24
|
+
pgpack_dumper/common/queryes/copy_from.sql,sha256=hEHfzW7P9-q74jtgMMA94kGpiMeyURs0pnFLbmqgdW0,50
|
25
|
+
pgpack_dumper/common/queryes/gpversion.sql,sha256=iUwW40pFCVAZhDZ6ah8CIW75_KMBLyvUxMyqOI7vxtA,80
|
26
|
+
pgpack_dumper/common/queryes/relkind.sql,sha256=wpyWaIiuCqQ0YaFPsNAEwwxSxuErNnRmP__-bfZ1vho,66
|
27
|
+
pgpack_dumper/common/queryes/copy_to.sql,sha256=AUSsFl_WFB88UcC45SLd8lD_1La1MIkV2CKX-gCOxEE,49
|
28
|
+
pgpack_dumper/common/queryes/attributes.sql,sha256=TriT025-yo7k9Bba3mKmpEYZiutE6ml4-5pAnGMemSg,394
|
29
|
+
pgpack_dumper/common/queryes/dbname.sql,sha256=Z3b6a_566PxA52ywRJw1JDSCUMC_c-FyulvW8mC1C7c,141
|
30
|
+
pgpack_dumper/common/queryes/prepare.sql,sha256=oqRk3GU0gjFzM0nLNsKWeD8GfeThZVKsFiMY1-tdb8g,182
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 0xMihalich
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1 @@
|
|
1
|
+
pgpack_dumper
|