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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Show file tree
Hide file tree
Changes fromall 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 deletionstestgres/connection.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionstestgres/operations/local_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 deletionstestgres/operations/os_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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 deletionstestgres/operations/remote_ops.py
View file
Open in desktop
Original file line numberDiff line numberDiff 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 DownExpand 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

[8]ページ先頭

©2009-2025 Movatter.jp