Skip to content

Commit 4f91179

Browse files
committed
Python: Model sqlite3.dbapi2
1 parent 6c0c06c commit 4f91179

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

python/ql/lib/semmle/python/frameworks/Stdlib.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2435,9 +2435,14 @@ private module StdlibPrivate {
24352435
* against a database.
24362436
*
24372437
* See https://devdocs.io/python~3.9/library/sqlite3
2438+
* https://github.com/python/cpython/blob/3.11/Lib/sqlite3/dbapi2.py
24382439
*/
24392440
class Sqlite3 extends PEP249::PEP249ModuleApiNode {
2440-
Sqlite3() { this = API::moduleImport("sqlite3") }
2441+
Sqlite3() {
2442+
this = API::moduleImport("sqlite3")
2443+
or
2444+
this = API::moduleImport("sqlite3").getMember("dbapi2")
2445+
}
24412446
}
24422447

24432448
// ---------------------------------------------------------------------------

python/ql/test/library-tests/frameworks/stdlib/pep249.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@
66

77
cursor = db.cursor()
88
cursor.execute("some sql", (42,)) # $ getSql="some sql"
9+
10+
import sqlite3.dbapi2
11+
conn = sqlite3.dbapi2.connect()
12+
cursor = conn.cursor()
13+
cursor.execute("some sql") # $ getSql="some sql"

0 commit comments

Comments
 (0)