def db_parameters(): """ Sets the db connection parameters """ ret = {} os.environ['TZ'] = 'UTC' if not IS_WINDOWS: time.tzset() # testaccount connection info for k, v in CONNECTION_PARAMETERS.items(): ret[k] = v for k, v in DEFAULT_PARAMETERS.items(): if k not in ret: ret[k] = v # s3 testaccount connection info. Not available in TravisCI if CONNECTION_PARAMETERS_S3: for k, v in CONNECTION_PARAMETERS_S3.items(): ret['s3_' + k] = v else: for k, v in CONNECTION_PARAMETERS.items(): ret['s3_' + k] = v # azure testaccount connection info. Not available in TravisCI if CONNECTION_PARAMETERS_AZURE: for k, v in CONNECTION_PARAMETERS_AZURE.items(): ret['azure_' + k] = v else: for k, v in CONNECTION_PARAMETERS.items(): ret['azure_' + k] = v # snowflake admin account. Not available in TravisCI for k, v in CONNECTION_PARAMETERS_ADMIN.items(): ret['sf_' + k] = v if 'host' in ret and ret['host'] == DEFAULT_PARAMETERS['host']: ret['host'] = ret['account'] + '.snowflakecomputing.com' if 'account' in ret and ret['account'] == DEFAULT_PARAMETERS['account']: help() sys.exit(2) # a unique table name ret['name'] = 'python_tests_' + TO_UNICODE(uuid.uuid4()).replace('-', '_') ret['name_wh'] = ret['name'] + 'wh' ret['schema'] = TEST_SCHEMA return ret
def db_parameters(): """ Sets the db connection parameters """ ret = {} os.environ['TZ'] = 'UTC' time.tzset() for k, v in CONNECTION_PARAMETERS.items(): ret[k] = v for k, v in DEFAULT_PARAMETERS.items(): if k not in ret: ret[k] = v if 'account' in ret and ret['account'] == DEFAULT_PARAMETERS['account']: help() sys.exit(2) if 'host' in ret and ret['host'] == DEFAULT_PARAMETERS['host']: ret['host'] = ret['account'] + '.snowflakecomputing.com' # a unique table name ret['name'] = ('sqlalchemy_tests_' + TO_UNICODE(uuid.uuid4())).replace( '-', '_') ret['schema'] = TEST_SCHEMA return ret
def db_parameters(): """ Sets the db connection parameters """ ret = {} os.environ['TZ'] = 'UTC' time.tzset() for k, v in CONNECTION_PARAMETERS.items(): ret[k] = v for k, v in DEFAULT_PARAMETERS.items(): if k not in ret: ret[k] = v if 'account' in ret and ret['account'] == DEFAULT_PARAMETERS['account']: help() sys.exit(2) if 'host' in ret and ret['host'] == DEFAULT_PARAMETERS['host']: ret['host'] = ret['account'] + '.snowflakecomputing.com' # a unique table name ret['name'] = ( 'sqlalchemy_tests_' + TO_UNICODE(uuid.uuid4())).replace('-', '_') ret['name_wh'] = ret['name'] + 'wh' return ret
def get_db_parameters(): """Sets the db connection parameters.""" ret = {} os.environ['TZ'] = 'UTC' if not IS_WINDOWS: time.tzset() # testaccount connection info for k, v in CONNECTION_PARAMETERS.items(): ret[k] = v for k, v in DEFAULT_PARAMETERS.items(): if k not in ret: ret[k] = v # snowflake admin account. Not available in GH actions for k, v in CONNECTION_PARAMETERS_ADMIN.items(): ret['sf_' + k] = v if 'host' in ret and ret['host'] == DEFAULT_PARAMETERS['host']: ret['host'] = ret['account'] + '.snowflakecomputing.com' if 'account' in ret and ret['account'] == DEFAULT_PARAMETERS['account']: help() sys.exit(2) # a unique table name ret['name'] = 'python_tests_' + str(uuid.uuid4()).replace('-', '_') ret['name_wh'] = ret['name'] + 'wh' ret['schema'] = TEST_SCHEMA # This reduces a chance to exposing password in test output. ret['a00'] = 'dummy parameter' ret['a01'] = 'dummy parameter' ret['a02'] = 'dummy parameter' ret['a03'] = 'dummy parameter' ret['a04'] = 'dummy parameter' ret['a05'] = 'dummy parameter' ret['a06'] = 'dummy parameter' ret['a07'] = 'dummy parameter' ret['a08'] = 'dummy parameter' ret['a09'] = 'dummy parameter' ret['a10'] = 'dummy parameter' ret['a11'] = 'dummy parameter' ret['a12'] = 'dummy parameter' ret['a13'] = 'dummy parameter' ret['a14'] = 'dummy parameter' ret['a15'] = 'dummy parameter' ret['a16'] = 'dummy parameter' return ret
def get_db_parameters(): """ Sets the db connection parameters """ ret = {} os.environ['TZ'] = 'UTC' if not IS_WINDOWS: time.tzset() for k, v in CONNECTION_PARAMETERS.items(): ret[k] = v for k, v in DEFAULT_PARAMETERS.items(): if k not in ret: ret[k] = v if 'account' in ret and ret['account'] == DEFAULT_PARAMETERS['account']: help() sys.exit(2) if 'host' in ret and ret['host'] == DEFAULT_PARAMETERS['host']: ret['host'] = ret['account'] + '.snowflakecomputing.com' # a unique table name ret['name'] = ('sqlalchemy_tests_' + TO_UNICODE(uuid.uuid4())).replace( '-', '_') ret['schema'] = TEST_SCHEMA # This reduces a chance to exposing password in test output. ret['a00'] = 'dummy parameter' ret['a01'] = 'dummy parameter' ret['a02'] = 'dummy parameter' ret['a03'] = 'dummy parameter' ret['a04'] = 'dummy parameter' ret['a05'] = 'dummy parameter' ret['a06'] = 'dummy parameter' ret['a07'] = 'dummy parameter' ret['a08'] = 'dummy parameter' ret['a09'] = 'dummy parameter' ret['a10'] = 'dummy parameter' ret['a11'] = 'dummy parameter' ret['a12'] = 'dummy parameter' ret['a13'] = 'dummy parameter' ret['a14'] = 'dummy parameter' ret['a15'] = 'dummy parameter' ret['a16'] = 'dummy parameter' return ret
def test_client_session_keep_alive(token_validity_test_values): test_connection_parameters = CONNECTION_PARAMETERS.copy() print("[INFO] Connected") test_connection_parameters['client_session_keep_alive'] = True with snowflake.connector.connect(**test_connection_parameters) as con: print("[INFO] Running a query. Ensuring a connection is valid.") con.cursor().execute("select 1") print("[INFO] Sleeping 15s") time.sleep(15) print("[INFO] Running a query. Both master and session tokens must " "have been renewed by token request") con.cursor().execute("select 1") print("[INFO] Sleeping 40s") time.sleep(40) print("[INFO] Running a query. Master token must have been renewed " "by the heartbeat") con.cursor().execute("select 1")