Пример не мой, взял у коллеги. Но у меня работает.
driver = ydb.Driver(
endpoint="",
database="",
credentials=""),
)
# Wait for the driver to become active for requests.
driver.wait(fail_fast=True, timeout=5)
# Create the session pool instance to manage YDB sessions.
pool = ydb.SessionPool(driver)
def execute_query(session):
# Create the transaction and execute query.
return session.transaction().execute(
'insert into dataTab (tel, SaleCount, TotalCount, stel) VALUES("9001002030", 4, 47, "8323");',
commit_tx=True,
settings=ydb.BaseRequestSettings().with_timeout(3).with_operation_timeout(2)
)
result = pool.retry_operation_sync(execute_query)