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

Commitda2c493

Browse files
OsOperation::db_connect is removed (#237)
* OsOperation::db_connect is removedOsOperation does not work with databases. It provides an only OS functional.TODO: CI must explicitly test pg8000 and psycopg2.
1 parent307ef5f commitda2c493

File tree

4 files changed

+8
-49
lines changed

4 files changed

+8
-49
lines changed

‎testgres/connection.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ def __init__(self,
4242

4343
self._node=node
4444

45-
self._connection=node.os_ops.db_connect(dbname=dbname,
46-
user=username,
47-
password=password,
48-
host=node.host,
49-
port=node.port)
45+
self._connection=pglib.connect(
46+
database=dbname,
47+
user=username,
48+
password=password,
49+
host=node.host,
50+
port=node.port
51+
)
5052

5153
self._connection.autocommit=autocommit
5254
self._cursor=self.connection.cursor()

‎testgres/operations/local_ops.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from ..exceptionsimportExecUtilException
1414
from ..exceptionsimportInvalidOperationException
15-
from .os_opsimportConnectionParams,OsOperations,pglib,get_default_encoding
15+
from .os_opsimportConnectionParams,OsOperations,get_default_encoding
1616
from .raise_errorimportRaiseError
1717
from .helpersimportHelpers
1818

@@ -446,14 +446,3 @@ def is_port_free(self, number: int) -> bool:
446446
returnTrue
447447
exceptOSError:
448448
returnFalse
449-
450-
# Database control
451-
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
452-
conn=pglib.connect(
453-
host=host,
454-
port=port,
455-
database=dbname,
456-
user=user,
457-
password=password,
458-
)
459-
returnconn

‎testgres/operations/os_ops.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
importgetpass
22
importlocale
33

4-
try:
5-
importpsycopg2aspglib# noqa: F401
6-
exceptImportError:
7-
try:
8-
importpg8000aspglib# noqa: F401
9-
exceptImportError:
10-
raiseImportError("You must have psycopg2 or pg8000 modules installed")
11-
124

135
classConnectionParams:
146
def__init__(self,host='127.0.0.1',port=None,ssh_key=None,username=None):
@@ -130,7 +122,3 @@ def get_process_children(self, pid):
130122
defis_port_free(self,number:int):
131123
asserttype(number)==int# noqa: E721
132124
raiseNotImplementedError()
133-
134-
# Database control
135-
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
136-
raiseNotImplementedError()

‎testgres/operations/remote_ops.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,6 @@
66
importio
77
importlogging
88

9-
# we support both pg8000 and psycopg2
10-
try:
11-
importpsycopg2aspglib
12-
exceptImportError:
13-
try:
14-
importpg8000aspglib
15-
exceptImportError:
16-
raiseImportError("You must have psycopg2 or pg8000 modules installed")
17-
189
from ..exceptionsimportExecUtilException
1910
from ..exceptionsimportInvalidOperationException
2011
from .os_opsimportOsOperations,ConnectionParams,get_default_encoding
@@ -677,17 +668,6 @@ def _is_port_free__process_1(error: str) -> bool:
677668
#
678669
returnTrue
679670

680-
# Database control
681-
defdb_connect(self,dbname,user,password=None,host="localhost",port=5432):
682-
conn=pglib.connect(
683-
host=host,
684-
port=port,
685-
database=dbname,
686-
user=user,
687-
password=password,
688-
)
689-
returnconn
690-
691671
@staticmethod
692672
def_make_exec_env_list()->list[str]:
693673
result=list[str]()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp