Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a64ba5

Browse files
committed
various improvements, change args of query performing functions
* changed args of psql(), safe_psql(), execute(), poll_query_until()* introduced positional_args_hack() decorator for API functions* replaced inline config names with constants in consts.py* introduced default_dbname(), changed default_username()
1 parent370c934 commit2a64ba5

File tree

8 files changed

+279
-120
lines changed

8 files changed

+279
-120
lines changed

‎.gitignore

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
*.pyc
2-
dist
3-
tags
4-
*.egg-info/
52
*.egg
6-
Dockerfile
7-
.coverage
3+
*.egg-info/
4+
dist
5+
86
env/
97
venv/
108
build/
9+
10+
.coverage
1111
coverage.xml
12+
13+
Dockerfile
14+
15+
*~
1216
*.swp
17+
tags

‎testgres/backup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from .constsimport \
1010
DATA_DIRas_DATA_DIR, \
11+
PG_CONF_FILEas_PG_CONF_FILE, \
1112
BACKUP_LOG_FILEas_BACKUP_LOG_FILE, \
1213
DEFAULT_XLOG_METHODas_DEFAULT_XLOG_METHOD
1314

@@ -139,8 +140,8 @@ def spawn_primary(self, name=None, destroy=True, use_logging=False):
139140
# New nodes should always remove dir tree
140141
node._should_rm_dirs=True
141142

142-
node.append_conf("postgresql.conf","\n")
143-
node.append_conf("postgresql.conf","port = {}".format(node.port))
143+
node.append_conf(_PG_CONF_FILE,"\n")
144+
node.append_conf(_PG_CONF_FILE,"port = {}".format(node.port))
144145

145146
returnnode
146147

‎testgres/connection.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
fromenumimportEnum
1313

1414
from .exceptionsimportQueryException
15-
from .utilsimportdefault_usernameas_default_username
15+
16+
from .utilsimport \
17+
default_dbnameas_default_dbname, \
18+
default_usernameas_default_username
19+
1620

1721
# export these exceptions
1822
InternalError=pglib.InternalError
@@ -33,25 +37,37 @@ class NodeConnection(object):
3337
"""
3438

3539
def__init__(self,
36-
parent_node,
37-
dbname,
38-
host="127.0.0.1",
40+
node,
41+
dbname=None,
3942
username=None,
4043
password=None):
4144

4245
# Use default user if not specified
46+
dbname=dbnameor_default_dbname()
4347
username=usernameor_default_username()
4448

45-
self.parent_node=parent_node
49+
self._node=node
4650

47-
self.connection=pglib.connect(
51+
self._connection=pglib.connect(
4852
database=dbname,
4953
user=username,
50-
port=parent_node.port,
51-
host=host,
52-
password=password)
54+
password=password,
55+
host=node.host,
56+
port=node.port)
57+
58+
self._cursor=self.connection.cursor()
59+
60+
@property
61+
defnode(self):
62+
returnself._node
63+
64+
@property
65+
defconnection(self):
66+
returnself._connection
5367

54-
self.cursor=self.connection.cursor()
68+
@property
69+
defcursor(self):
70+
returnself._cursor
5571

5672
def__enter__(self):
5773
returnself
@@ -73,7 +89,7 @@ def begin(self, isolation_level=IsolationLevel.ReadCommitted):
7389

7490
# Get index of isolation level
7591
level_idx=isolation_level.value
76-
assert(level_idxinrange(4))
92+
assertlevel_idxinrange(4)
7793

7894
# Replace isolation level with its name
7995
isolation_level=levels[level_idx]

‎testgres/consts.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
DATA_DIR="data"
55
LOGS_DIR="logs"
66

7+
RECOVERY_CONF_FILE="recovery.conf"
8+
PG_CONF_FILE="postgresql.conf"
9+
HBA_CONF_FILE="pg_hba.conf"
10+
711
# names for log files
812
PG_LOG_FILE="postgresql.log"
913
UTILS_LOG_FILE="utils.log"

‎testgres/logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
classTestgresLogger(threading.Thread):
1010
"""
11-
Helper class to implement reading frompostgresql.log
11+
Helper class to implement reading from log files.
1212
"""
1313

1414
def__init__(self,node_name,log_file_name):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp