Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

OsOperation::db_connect is removed #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions testgres/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ def __init__(self,

self._node = node

self._connection = node.os_ops.db_connect(dbname=dbname,
user=username,
password=password,
host=node.host,
port=node.port)
self._connection = pglib.connect(
database=dbname,
user=username,
password=password,
host=node.host,
port=node.port
)

self._connection.autocommit = autocommit
self._cursor = self.connection.cursor()
Expand Down
13 changes: 1 addition & 12 deletions testgres/operations/local_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ..exceptions import ExecUtilException
from ..exceptions import InvalidOperationException
from .os_ops import ConnectionParams, OsOperations, pglib, get_default_encoding
from .os_ops import ConnectionParams, OsOperations, get_default_encoding
from .raise_error import RaiseError
from .helpers import Helpers

Expand Down Expand Up @@ -446,14 +446,3 @@ def is_port_free(self, number: int) -> bool:
return True
except OSError:
return False

# Database control
def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
conn = pglib.connect(
host=host,
port=port,
database=dbname,
user=user,
password=password,
)
return conn
12 changes: 0 additions & 12 deletions testgres/operations/os_ops.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import getpass
import locale

try:
import psycopg2 as pglib # noqa: F401
except ImportError:
try:
import pg8000 as pglib # noqa: F401
except ImportError:
raise ImportError("You must have psycopg2 or pg8000 modules installed")


class ConnectionParams:
def __init__(self, host='127.0.0.1', port=None, ssh_key=None, username=None):
Expand Down Expand Up @@ -130,7 +122,3 @@ def get_process_children(self, pid):
def is_port_free(self, number: int):
assert type(number) == int # noqa: E721
raise NotImplementedError()

# Database control
def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
raise NotImplementedError()
20 changes: 0 additions & 20 deletions testgres/operations/remote_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@
import io
import logging

# we support both pg8000 and psycopg2
try:
import psycopg2 as pglib
except ImportError:
try:
import pg8000 as pglib
except ImportError:
raise ImportError("You must have psycopg2 or pg8000 modules installed")

from ..exceptions import ExecUtilException
from ..exceptions import InvalidOperationException
from .os_ops import OsOperations, ConnectionParams, get_default_encoding
Expand Down Expand Up @@ -677,17 +668,6 @@ def _is_port_free__process_1(error: str) -> bool:
#
return True

# Database control
def db_connect(self, dbname, user, password=None, host="localhost", port=5432):
conn = pglib.connect(
host=host,
port=port,
database=dbname,
user=user,
password=password,
)
return conn

@staticmethod
def _make_exec_env_list() -> list[str]:
result = list[str]()
Expand Down