44def test_driver_works (driver : ydb .Driver ):
55 driver .wait (5 )
66 pool = ydb .QuerySessionPool (driver )
7- pool .execute_with_retries ("SELECT 1" )
8- print ( "everything is fine" )
7+ result = pool .execute_with_retries ("SELECT 1 as cnt " )
8+ assert result [ 0 ]. rows [ 0 ]. cnt == 1
99
1010
11- def auth_with_static_credentials_old (endpoint : str , database : str , user : str , password : str ):
12- driver_config_temp = ydb .DriverConfig (
13- endpoint = endpoint ,
14- database = database ,
15- )
16- creds = ydb .StaticCredentials (
17- driver_config = driver_config_temp ,
18- user = user ,
19- password = password ,
20- )
21-
22- driver_config = ydb .DriverConfig (
23- endpoint = endpoint ,
24- database = database ,
25- credentials = creds ,
26- )
27-
28- with ydb .Driver (driver_config = driver_config ) as driver :
29- test_driver_works (driver )
30-
31-
32- def auth_with_static_credentials_new (endpoint : str , database : str , user : str , password : str ):
33- driver_config = ydb .DriverConfig (
34- endpoint = endpoint ,
35- database = database ,
36- )
37- creds = ydb .StaticCredentials (
38- driver_config = driver_config ,
39- user = user ,
40- password = password ,
41- )
42-
43- with ydb .Driver (driver_config = driver_config , credentials = creds ) as driver :
44- test_driver_works (driver )
45-
46-
47- def auth_with_static_credentials_new2 (endpoint : str , database : str , user : str , password : str ):
11+ def auth_with_static_credentials (endpoint : str , database : str , user : str , password : str ):
4812 driver_config = ydb .DriverConfig (
4913 endpoint = endpoint ,
5014 database = database ,
@@ -55,24 +19,5 @@ def auth_with_static_credentials_new2(endpoint: str, database: str, user: str, p
5519 test_driver_works (driver )
5620
5721
58- def auth_with_user_password_credentials (endpoint : str , database : str , user : str , password : str ):
59- driver_config = ydb .DriverConfig (
60- endpoint = endpoint ,
61- database = database ,
62- credentials = ydb .UserPasswordCredentials (
63- user = user ,
64- password = password ,
65- endpoint = endpoint ,
66- database = database ,
67- ),
68- )
69-
70- with ydb .Driver (driver_config = driver_config ) as driver :
71- test_driver_works (driver )
72-
73-
7422def run (endpoint : str , database : str , user : str , password : str ):
75- auth_with_static_credentials_old (endpoint , database , user , password )
76- auth_with_static_credentials_new (endpoint , database , user , password )
77- auth_with_static_credentials_new2 (endpoint , database , user , password )
78- auth_with_user_password_credentials (endpoint , database , user , password )
23+ auth_with_static_credentials (endpoint , database , user , password )
0 commit comments