forked from snowflakedb/snowflake-connector-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_statement_parameter_binding.py
More file actions
49 lines (41 loc) · 1.31 KB
/
test_statement_parameter_binding.py
File metadata and controls
49 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2018 Snowflake Computing Inc. All right reserved.
#
from datetime import datetime
import pytz
import pytest
try:
from parameters import (CONNECTION_PARAMETERS_ADMIN)
except:
CONNECTION_PARAMETERS_ADMIN = {}
@pytest.mark.skipif(
not CONNECTION_PARAMETERS_ADMIN,
reason="Snowflake admin account is not accessible."
)
def test_binding_security(conn_cnx):
"""
Binding statement parameters
"""
expected_qa_mode_datetime = datetime(1967, 6, 23, 7, 0, 0, 123000, pytz.UTC)
with conn_cnx() as cnx:
cnx.cursor().execute("alter session set timezone='UTC'")
with cnx.cursor() as cur:
cur.execute(
"show databases like 'TESTDB'")
rec = cur.fetchone()
assert rec[0] != expected_qa_mode_datetime
with cnx.cursor() as cur:
cur.execute(
"show databases like 'TESTDB'",
_statement_params={
'QA_MODE': True,
})
rec = cur.fetchone()
assert rec[0] == expected_qa_mode_datetime
with cnx.cursor() as cur:
cur.execute(
"show databases like 'TESTDB'")
rec = cur.fetchone()
assert rec[0] != expected_qa_mode_datetime