File tree Expand file tree Collapse file tree
python/ql/test/experimental/semmle/python/frameworks Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import python
2+ import experimental.meta.ConceptsTest
23import experimental.semmle.python.frameworks.ClickHouseDriver
3- import semmle.python.Concepts
4-
5- from SqlExecution s
6- select s , s .getSql ( )
Original file line number Diff line number Diff line change 1+ semmle-extractor-options: --max-import-depth=1 --lang=3
Original file line number Diff line number Diff line change 1+ import aioch
2+
3+
4+ SQL = "SOME SQL"
5+
6+
7+ async def aioch_test ():
8+ client = aioch .Client ("localhost" )
9+
10+ await client .execute (SQL ) # $ getSql=SQL
11+ await client .execute (query = SQL ) # $ MISSING: getSql=SQL
12+
13+ await client .execute_with_progress (SQL ) # $ getSql=SQL
14+ await client .execute_with_progress (query = SQL ) # $ MISSING: getSql=SQL
15+
16+ await client .execute_iter (SQL ) # $ getSql=SQL
17+ await client .execute_iter (query = SQL ) # $ MISSING: getSql=SQL
18+
19+
20+ # Using custom client (this has been seen done for the blocking version in
21+ # `clickhouse_driver` PyPI package)
22+
23+
24+ class MyClient (aioch .Client ):
25+ pass
26+
27+
28+ async def test_custom_client ():
29+ client = MyClient ("localhost" )
30+ await client .execute (SQL ) # $ getSql=SQL
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ import python
2+ import experimental.meta.ConceptsTest
3+ import experimental.semmle.python.frameworks.ClickHouseDriver
Original file line number Diff line number Diff line change 1+ import clickhouse_driver
2+
3+
4+ SQL = "SOME SQL"
5+
6+
7+ # Normal operation
8+ client = clickhouse_driver .client .Client ("localhost" )
9+
10+ client .execute (SQL ) # $ MISSING: getSql=SQL
11+ client .execute (query = SQL ) # $ MISSING: getSql=SQL
12+
13+ client .execute_with_progress (SQL ) # $ MISSING: getSql=SQL
14+ client .execute_with_progress (query = SQL ) # $ MISSING: getSql=SQL
15+
16+ client .execute_iter (SQL ) # $ MISSING: getSql=SQL
17+ client .execute_iter (query = SQL ) # $ MISSING: getSql=SQL
18+
19+
20+ # commonly used alias
21+ client = clickhouse_driver .Client ("localhost" )
22+ client .execute (SQL ) # $ getSql=SQL
23+
24+
25+ # Using PEP249 interface
26+ conn = clickhouse_driver .connect ('clickhouse://localhost' )
27+ cursor = conn .cursor ()
28+ cursor .execute (SQL ) # $ getSql=SQL
29+
30+
31+ # Using custom client
32+ #
33+ # examples from real world code
34+ # https://github.com/Altinity/clickhouse-mysql-data-reader/blob/3b1b7088751b05e5bbf45890c5949b58208c2343/clickhouse_mysql/dbclient/chclient.py#L10
35+ # https://github.com/Felixoid/clickhouse-plantuml/blob/d8b2ba7d164a836770ec21f5e4035dfb04c41d9c/clickhouse_plantuml/client.py#L9
36+
37+
38+ class MyClient (clickhouse_driver .Client ):
39+ pass
40+
41+
42+ MyClient ("localhost" ).execute (SQL ) # $ getSql=SQL
Original file line number Diff line number Diff line change 1+ semmle-extractor-options: --max-import-depth=1
You can’t perform that action at this time.
0 commit comments