Skip to content

Commit 8807edd

Browse files
committed
Rename to ydb_table_path_prefix
1 parent 98682ad commit 8807edd

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

test/test_core.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ def test_index_with_join_usage(self, connection: sa.Connection, metadata: sa.Met
997997
assert cursor.one() == ("Sarah Connor", "wanted")
998998

999999

1000-
class TestRootDirectory(TablesTest):
1000+
class TestTablePathPrefix(TablesTest):
10011001
__backend__ = True
10021002

10031003
@classmethod
@@ -1013,8 +1013,8 @@ def insert_data(cls, connection: sa.Connection):
10131013
connection.execute(sa.insert(table).values({"id": 1}))
10141014
connection.execute(sa.insert(root_table).values({"id": 2}))
10151015

1016-
def test_root_directory(self):
1017-
engine = sa.create_engine(config.db_url, connect_args={"ydb_root_directory": "/local/some_dir/nested_dir"})
1016+
def test_select(self):
1017+
engine = sa.create_engine(config.db_url, connect_args={"ydb_table_path_prefix": "/local/some_dir/nested_dir"})
10181018
rel_table = Table("table", sa.MetaData(), sa.Column("id", sa.Integer, primary_key=True))
10191019
abs_table = Table("/local/table", sa.MetaData(), sa.Column("id", sa.Integer, primary_key=True))
10201020

@@ -1026,8 +1026,10 @@ def test_root_directory(self):
10261026
assert result2 == 2
10271027

10281028
def test_two_engines(self):
1029-
create_engine = sa.create_engine(config.db_url, connect_args={"ydb_root_directory": "/local/two/engines/test"})
1030-
select_engine = sa.create_engine(config.db_url, connect_args={"ydb_root_directory": "/local/two"})
1029+
create_engine = sa.create_engine(
1030+
config.db_url, connect_args={"ydb_table_path_prefix": "/local/two/engines/test"}
1031+
)
1032+
select_engine = sa.create_engine(config.db_url, connect_args={"ydb_table_path_prefix": "/local/two"})
10311033
table_to_create = Table("table", sa.MetaData(), sa.Column("id", sa.Integer, primary_key=True))
10321034
table_to_select = Table("engines/test/table", sa.MetaData(), sa.Column("id", sa.Integer, primary_key=True))
10331035

@@ -1044,7 +1046,7 @@ def test_two_engines(self):
10441046
assert result == 42
10451047

10461048
def test_reflection(self):
1047-
reflection_engine = sa.create_engine(config.db_url, connect_args={"ydb_root_directory": "/local/some_dir"})
1049+
reflection_engine = sa.create_engine(config.db_url, connect_args={"ydb_table_path_prefix": "/local/some_dir"})
10481050
metadata = sa.MetaData()
10491051

10501052
metadata.reflect(reflection_engine)

ydb_sqlalchemy/dbapi/connection.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
self.database = database
3939
self.conn_kwargs = conn_kwargs
4040
self.credentials = self.conn_kwargs.pop("credentials", None)
41-
self.root_directory = self.conn_kwargs.pop("ydb_root_directory", "")
41+
self.table_path_prefix = self.conn_kwargs.pop("ydb_table_path_prefix", "")
4242

4343
if "ydb_session_pool" in self.conn_kwargs: # Use session pool managed manually
4444
self._shared_session_pool = True
@@ -59,20 +59,20 @@ def __init__(
5959
self.tx_context: Optional[ydb.TxContext] = None
6060

6161
def cursor(self):
62-
return self._cursor_class(self.session_pool, self.tx_mode, self.tx_context, self.root_directory)
62+
return self._cursor_class(self.session_pool, self.tx_mode, self.tx_context, self.table_path_prefix)
6363

6464
def describe(self, table_path: str) -> ydb.TableDescription:
65-
abs_table_path = posixpath.join(self.database, self.root_directory, table_path)
65+
abs_table_path = posixpath.join(self.database, self.table_path_prefix, table_path)
6666
cursor = self.cursor()
6767
return cursor.describe_table(abs_table_path)
6868

6969
def check_exists(self, table_path: str) -> ydb.SchemeEntry:
70-
abs_table_path = posixpath.join(self.database, self.root_directory, table_path)
70+
abs_table_path = posixpath.join(self.database, self.table_path_prefix, table_path)
7171
cursor = self.cursor()
7272
return cursor.check_exists(abs_table_path)
7373

7474
def get_table_names(self) -> List[str]:
75-
abs_dir_path = posixpath.join(self.database, self.root_directory)
75+
abs_dir_path = posixpath.join(self.database, self.table_path_prefix)
7676
cursor = self.cursor()
7777
return [posixpath.relpath(path, abs_dir_path) for path in cursor.get_table_names(abs_dir_path)]
7878

ydb_sqlalchemy/dbapi/cursor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __init__(
7979
session_pool: Union[ydb.SessionPool, ydb.aio.SessionPool],
8080
tx_mode: ydb.AbstractTransactionModeBuilder,
8181
tx_context: Optional[ydb.BaseTxContext] = None,
82-
root_directory: str = "",
82+
table_path_prefix: str = "",
8383
):
8484
self.session_pool = session_pool
8585
self.tx_mode = tx_mode
@@ -88,7 +88,7 @@ def __init__(
8888
self.arraysize = 1
8989
self.rows = None
9090
self._rows_prefetched = None
91-
self.root_directory = root_directory
91+
self.root_directory = table_path_prefix
9292

9393
@_handle_ydb_errors
9494
def describe_table(self, abs_table_path: str) -> ydb.TableDescription:

0 commit comments

Comments
 (0)