Skip to content

Commit f1bdd74

Browse files
authored
Merge pull request #47 from ydb-platform/improve-example
improve example: avoid os.path.join
2 parents 16d979c + 0c1f45a commit f1bdd74

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Diff for: examples/basic_example_v1/basic_example.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
2-
import os
3-
2+
import posixpath
43
import ydb
54
import basic_example_data
65

@@ -258,7 +257,7 @@ def callee(session):
258257

259258
def describe_table(pool, path, name):
260259
def callee(session):
261-
result = session.describe_table(os.path.join(path, name))
260+
result = session.describe_table(posixpath.join(path, name))
262261
print("\n> describe table: series")
263262
for column in result.columns:
264263
print("column, name:", column.name, ",", str(column.type.item).strip())
@@ -277,7 +276,7 @@ def bulk_upsert(table_client, path):
277276
.add_column("air_date", ydb.OptionalType(ydb.PrimitiveType.Uint64))
278277
)
279278
rows = basic_example_data.get_episodes_data_for_bulk_upsert()
280-
table_client.bulk_upsert(os.path.join(path, "episodes"), rows, column_types)
279+
table_client.bulk_upsert(posixpath.join(path, "episodes"), rows, column_types)
281280

282281

283282
def is_directory_exists(driver, path):
@@ -291,11 +290,11 @@ def ensure_path_exists(driver, database, path):
291290
paths_to_create = list()
292291
path = path.rstrip("/")
293292
while path not in ("", database):
294-
full_path = os.path.join(database, path)
293+
full_path = posixpath.join(database, path)
295294
if is_directory_exists(driver, full_path):
296295
break
297296
paths_to_create.append(full_path)
298-
path = os.path.dirname(path).rstrip("/")
297+
path = posixpath.dirname(path).rstrip("/")
299298

300299
while len(paths_to_create) > 0:
301300
full_path = paths_to_create.pop(-1)
@@ -310,7 +309,7 @@ def run(endpoint, database, path):
310309

311310
ensure_path_exists(driver, database, path)
312311

313-
full_path = os.path.join(database, path)
312+
full_path = posixpath.join(database, path)
314313

315314
create_tables(pool, full_path)
316315

0 commit comments

Comments
 (0)