rda-python-dbms 2.0.7__py3-none-any.whl → 2.0.9__py3-none-any.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.
- rda_python_dbms/pgbackup.py +1 -1
- rda_python_dbms/pgdbdump.py +51 -29
- rda_python_dbms/pgdbrestore.py +3 -3
- rda_python_dbms/tables/dssdb/dsgroup.json +1 -1
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/METADATA +1 -1
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/RECORD +10 -10
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/WHEEL +0 -0
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/entry_points.txt +0 -0
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/licenses/LICENSE +0 -0
- {rda_python_dbms-2.0.7.dist-info → rda_python_dbms-2.0.9.dist-info}/top_level.txt +0 -0
rda_python_dbms/pgbackup.py
CHANGED
|
@@ -50,7 +50,7 @@ class PgBackup(PgFile):
|
|
|
50
50
|
elif option == 'o':
|
|
51
51
|
self.override = True
|
|
52
52
|
else:
|
|
53
|
-
self.pglog("{}:
|
|
53
|
+
self.pglog("{}: unknown option".format(arg), self.LGEREX)
|
|
54
54
|
self.cmdlog("pgbackup {}".format(' '.join(argv)))
|
|
55
55
|
|
|
56
56
|
# start actions
|
rda_python_dbms/pgdbdump.py
CHANGED
|
@@ -12,7 +12,7 @@ import sys
|
|
|
12
12
|
import re
|
|
13
13
|
import os
|
|
14
14
|
from os import path as op
|
|
15
|
-
from rda_python_common.
|
|
15
|
+
from rda_python_common.pg_util import PgUtil
|
|
16
16
|
|
|
17
17
|
class PgDBDump(PgUtil):
|
|
18
18
|
def __init__(self):
|
|
@@ -23,58 +23,80 @@ class PgDBDump(PgUtil):
|
|
|
23
23
|
self.SNDACT = self.LOGWRN|self.SNDEML
|
|
24
24
|
self.pname = self.hname = self.dname = None
|
|
25
25
|
|
|
26
|
-
# function to read_parameters
|
|
27
26
|
def read_parameters(self):
|
|
28
|
-
|
|
27
|
+
"""
|
|
28
|
+
Parse command-line options and set instance variables.
|
|
29
|
+
Usage: pgdbdump [-b] -d DBNAME -h HostName [-p LocalPath]
|
|
30
|
+
"""
|
|
29
31
|
self.PGLOG['LOGFILE'] = "pgbackup.log" # set log file
|
|
30
32
|
argv = sys.argv[1:]
|
|
31
33
|
option = None
|
|
32
34
|
options = ['b', 'd', 'h', 'p']
|
|
33
|
-
|
|
35
|
+
i = 0
|
|
36
|
+
while i < len(argv):
|
|
37
|
+
arg = argv[i]
|
|
34
38
|
ms = re.match(r'^-(\w)$', arg)
|
|
35
39
|
if ms:
|
|
36
40
|
option = ms.group(1)
|
|
37
|
-
if option not in options:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
if option not in options:
|
|
42
|
+
self.pglog(f"{arg}: unknown option", self.LGEREX)
|
|
43
|
+
if option == 'b':
|
|
44
|
+
self.PGLOG['BCKGRND'] = 1
|
|
45
|
+
option = None
|
|
46
|
+
i += 1
|
|
47
|
+
continue
|
|
48
|
+
# For options that require a value
|
|
49
|
+
if i + 1 >= len(argv):
|
|
50
|
+
self.pglog(f"Option -{option} requires a value", self.LGEREX)
|
|
51
|
+
val = argv[i+1]
|
|
52
|
+
if option == 'd':
|
|
53
|
+
self.dname = val
|
|
54
|
+
elif option == 'h':
|
|
55
|
+
self.hname = val
|
|
56
|
+
elif option == 'p':
|
|
57
|
+
self.pname = val
|
|
58
|
+
i += 2
|
|
59
|
+
option = None
|
|
60
|
+
else:
|
|
61
|
+
i += 1
|
|
45
62
|
if not (self.dname and self.hname):
|
|
46
63
|
print("Usage: pgdbdump [-b] -d DBNAME -h HostName [-p LocalPath]")
|
|
47
64
|
print(" -b - background process and no screen output")
|
|
48
65
|
print(" -d - PostgreSQL database name to dump at the current directory")
|
|
49
66
|
print(" -h - Hostname the PostgreSQL server is running on")
|
|
50
67
|
print(" -p - Local relative path to dump the database, defaults to <DBNAME>_backup_<TODAY>")
|
|
51
|
-
sys.exit(
|
|
68
|
+
sys.exit(1)
|
|
52
69
|
self.cmdlog("pgdbdump {}".format(' '.join(argv)))
|
|
53
|
-
if not self.pname:
|
|
70
|
+
if not self.pname:
|
|
71
|
+
short_host = self.hname.split('.')[0] if self.hname else 'host'
|
|
72
|
+
today = self.curdate()
|
|
73
|
+
self.pname = f"{short_host}_{self.dname}_{today}"
|
|
54
74
|
|
|
55
|
-
# function to start_actions
|
|
56
75
|
def start_actions(self):
|
|
76
|
+
"""Perform the database dump and log actions."""
|
|
57
77
|
self.pg_database_dbdump()
|
|
58
|
-
title = "pgdbdump: {}:{
|
|
59
|
-
tmsg = "{} to {} under {
|
|
78
|
+
title = f"pgdbdump: {self.hname}:{self.dname}:{self.pname}"
|
|
79
|
+
tmsg = f"{title} to {self.pname} under {os.getcwd()}!"
|
|
60
80
|
self.set_email(tmsg, self.EMLTOP)
|
|
61
81
|
self.pglog(title, self.SNDACT)
|
|
62
|
-
self.cmdlog()
|
|
82
|
+
self.cmdlog()
|
|
63
83
|
|
|
64
|
-
# bacup one database
|
|
65
84
|
def pg_database_dbdump(self):
|
|
66
|
-
|
|
85
|
+
"""Run pg_dump for the specified database and handle errors."""
|
|
86
|
+
cmd = f"pg_dump {self.dname} -h {self.hname} -U {self.USNAME} -w -Fd -j 16 -f {self.pname}/"
|
|
67
87
|
if op.exists(self.pname):
|
|
68
|
-
self.pglog(self.pname + ": Dumping directory exists,
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
self.pglog(self.pname + ": Dumping directory exists, aborting to avoid overwrite.", self.ERRACT)
|
|
89
|
+
sys.exit(2)
|
|
90
|
+
if not self.pgsystem(cmd, self.LOGACT, 257):
|
|
91
|
+
self.pglog(f"{self.dname}: Error dumping database\n{self.PGLOG['SYSERR']}", self.ERRACT)
|
|
92
|
+
sys.exit(3)
|
|
71
93
|
|
|
72
|
-
# main function to
|
|
94
|
+
# main function to execute this script
|
|
73
95
|
def main():
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
pgdb = PgDBDump()
|
|
97
|
+
pgdb.read_parameters()
|
|
98
|
+
pgdb.start_actions()
|
|
99
|
+
pgdb.pgexit(0)
|
|
78
100
|
|
|
79
101
|
# call main() to start program
|
|
80
|
-
if __name__ == "__main__": main()
|
|
102
|
+
if __name__ == "__main__": main()
|
rda_python_dbms/pgdbrestore.py
CHANGED
|
@@ -35,7 +35,7 @@ class PgDBRestore(PgDBI):
|
|
|
35
35
|
ms = re.match(r'^-(\w)$', arg)
|
|
36
36
|
if ms:
|
|
37
37
|
option = ms.group(1)
|
|
38
|
-
if option not in options: self.pglog("{}:
|
|
38
|
+
if option not in options: self.pglog("{}: unknown option".format(arg), self.LGEREX)
|
|
39
39
|
if option == 'b': self.PGLOG['BCKGRND'] = 1
|
|
40
40
|
elif option == 'd':
|
|
41
41
|
self.dname = arg
|
|
@@ -61,7 +61,7 @@ class PgDBRestore(PgDBI):
|
|
|
61
61
|
self.pglog(title, self.SNDACT)
|
|
62
62
|
self.cmdlog()
|
|
63
63
|
|
|
64
|
-
#
|
|
64
|
+
# restore one database
|
|
65
65
|
def pg_database_dbrestore(self):
|
|
66
66
|
cmd = "pg_restore -d {} -h {} -U {} -w -j 16 -Fd {}".format(self.dname, self.hname, self.USNAME, self.pname)
|
|
67
67
|
if not op.exists(self.pname):
|
|
@@ -69,7 +69,7 @@ class PgDBRestore(PgDBI):
|
|
|
69
69
|
elif not self.pgsystem(cmd, self.LOGACT, 257):
|
|
70
70
|
self.pglog("{}: Error restoring database\n{}".format(self.dname, self.PGLOG['SYSERR']), self.ERRACT)
|
|
71
71
|
|
|
72
|
-
# main function to
|
|
72
|
+
# main function to execute this script
|
|
73
73
|
def main():
|
|
74
74
|
object = PgDBRestore()
|
|
75
75
|
object.read_parameters()
|
|
@@ -9,11 +9,11 @@ rda_python_dbms/pg_ddl.py,sha256=77Cil6eBKf5S5g7yWcN9m5dLZlpY3_USFQBKcaP4fiU,544
|
|
|
9
9
|
rda_python_dbms/pg_ddllib.py,sha256=-zawllfUCe7QZNvza-u5TAYKP4yilC9K6TetHhoGenU,44265
|
|
10
10
|
rda_python_dbms/pg_schema.py,sha256=Vsf5fKENYIOgMKE3yS0TkXhg-aeHZ2nYzpvltFAcdFY,5520
|
|
11
11
|
rda_python_dbms/pg_seq.py,sha256=wNxqsyIjcTplJErPirZ-VkZ8HS4mgQUwPz8Xwd12kYA,4914
|
|
12
|
-
rda_python_dbms/pgbackup.py,sha256=
|
|
12
|
+
rda_python_dbms/pgbackup.py,sha256=IuP3nQEEVR86YlSZuGyqsdz1-O9rgET76FnWB7iL3xk,4249
|
|
13
13
|
rda_python_dbms/pgchksum.py,sha256=8jfBncptxp57Gr2t66Kk9MFt5Z_aXfozOGZPaohKGwM,21802
|
|
14
14
|
rda_python_dbms/pgcmptables.py,sha256=LQ4KK4JuQs2z3nBdINWYgyiGu2MF9RZjS5_cAktbs6k,47123
|
|
15
|
-
rda_python_dbms/pgdbdump.py,sha256=
|
|
16
|
-
rda_python_dbms/pgdbrestore.py,sha256=
|
|
15
|
+
rda_python_dbms/pgdbdump.py,sha256=8d-1z16Y2DyJnQqex2wFu5svChKgncPnzdQ-iUftHg8,3831
|
|
16
|
+
rda_python_dbms/pgdbrestore.py,sha256=d12hl1r6usK1oGIFAPVWUB_KkIH04PPlugxVSnLOX1g,3110
|
|
17
17
|
rda_python_dbms/pgddl.py,sha256=kHTtWzetAwaS8GEG9x8KBLwW-RqMJ-2cbGDlYtJOSH8,6198
|
|
18
18
|
rda_python_dbms/pgddl.usg,sha256=7ly6YbusvyIy9yQn9reGIUtZQ5Wiehp9-DKDgfjqSBE,2267
|
|
19
19
|
rda_python_dbms/pgschema.py,sha256=ZLkRy2vgfkRYWQ95bGXkz13n5LR5wrdki6WV5ZA8eL0,6293
|
|
@@ -61,7 +61,7 @@ rda_python_dbms/tables/dssdb/dscart.json,sha256=ggVt5SVi1EbNc9bEA7dCRRF4l7pOZIHm
|
|
|
61
61
|
rda_python_dbms/tables/dssdb/dscheck.json,sha256=ZL6VNerF2PGcP0yPFUXhq7dzJDc5g5xX64eURAghGNY,6426
|
|
62
62
|
rda_python_dbms/tables/dssdb/dschkhist.json,sha256=UeTjTsIpBGGscPNajL1tl7uflQWbYe3ILkyBcDBb9Mc,2880
|
|
63
63
|
rda_python_dbms/tables/dssdb/dsdaemon.json,sha256=Ua0TktcZ5RPEQbwEblnNjWRBjDp-xcuunsaCAIaXsx0,1859
|
|
64
|
-
rda_python_dbms/tables/dssdb/dsgroup.json,sha256=
|
|
64
|
+
rda_python_dbms/tables/dssdb/dsgroup.json,sha256=aZ7RtRWnRcIruQesdsbUglHxvb8tROfNoWMNP0Bfzdk,5389
|
|
65
65
|
rda_python_dbms/tables/dssdb/dshist.json,sha256=EEpCLLwS0vfV9OwMWgrRmvHP81gMybG8NOTxtDeHR1Y,1396
|
|
66
66
|
rda_python_dbms/tables/dssdb/dslimit.json,sha256=hdpRAC4Bg0ZUCwVVDCCHVwYJcDLotXFB2e30G7ByzKg,758
|
|
67
67
|
rda_python_dbms/tables/dssdb/dsokeys.json,sha256=4c_AsQgxBApawhnkKTzXflxL-603J19z8poimxe_sXw,746
|
|
@@ -954,9 +954,9 @@ rda_python_dbms/tables/obsua/wind_5v2_0.json,sha256=NehMFE-GMNlD5Bh_fiacfSOmZWkr
|
|
|
954
954
|
rda_python_dbms/tables/obsua/wind_60v2_0.json,sha256=jOyQgD5ph7YBMuQfvYz1Ln6X_-_Vdhl36HBexOHZ1dA,1067
|
|
955
955
|
rda_python_dbms/tables/obsua/wind_8v2_0.json,sha256=5wtCThmFeOyiAGH_Qv3_jrXjhjo9b87ehlpI9QQY2SM,1064
|
|
956
956
|
rda_python_dbms/tables/obsua/wind_9v2_0.json,sha256=7OKFUicOn15LL_WuF1VE_L8DjxsHmRP4uBnopuMIeTg,1064
|
|
957
|
-
rda_python_dbms-2.0.
|
|
958
|
-
rda_python_dbms-2.0.
|
|
959
|
-
rda_python_dbms-2.0.
|
|
960
|
-
rda_python_dbms-2.0.
|
|
961
|
-
rda_python_dbms-2.0.
|
|
962
|
-
rda_python_dbms-2.0.
|
|
957
|
+
rda_python_dbms-2.0.9.dist-info/licenses/LICENSE,sha256=Uky6fiiVw7cakFVRtVpzg-mvqOQ-WcA_H8lHqhPRg58,1101
|
|
958
|
+
rda_python_dbms-2.0.9.dist-info/METADATA,sha256=8jhKTRIo91_CXYgIdyMBwXbCZQ1VOpS-1ghgC6NxVbI,617
|
|
959
|
+
rda_python_dbms-2.0.9.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
960
|
+
rda_python_dbms-2.0.9.dist-info/entry_points.txt,sha256=iti6iZS2OEeBqO5aHlWeMFcbuwN_2assidP0qeSkQ6E,346
|
|
961
|
+
rda_python_dbms-2.0.9.dist-info/top_level.txt,sha256=4T1ShNUMyiqmwDIuDL7pDOm_S-6zWWW3Vy6OdAzYA4c,16
|
|
962
|
+
rda_python_dbms-2.0.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|