@@ -28,74 +28,68 @@ module Streamlit {
28
28
29
29
override string getSourceType ( ) { result = "Streamlit user input" }
30
30
}
31
- /**
32
- * The Streamlit SQLConnection class, which is used to create a connection to a SQL Database.
33
- * Streamlit wraps around SQL Alchemy for most database functionality, and adds some on top of it, such as the `query` method.
34
- * Streamlit can also connect to Snowflake and Snowpark databases, but the modeling is not the same, so we need to limit the scope to SQL databases.
35
- * https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection#:~:text=to%20data.-,st.connections.SQLConnection,-Streamlit%20Version
36
- * We can connect to SQL databases for example with `import streamlit as st; conn = st.connection('pets_db', type='sql')`
37
- */
31
+
32
+ /**
33
+ * The Streamlit SQLConnection class, which is used to create a connection to a SQL Database.
34
+ * Streamlit wraps around SQL Alchemy for most database functionality, and adds some on top of it, such as the `query` method.
35
+ * Streamlit can also connect to Snowflake and Snowpark databases, but the modeling is not the same, so we need to limit the scope to SQL databases.
36
+ * https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection#:~:text=to%20data.-,st.connections.SQLConnection,-Streamlit%20Version
37
+ * We can connect to SQL databases for example with `import streamlit as st; conn = st.connection('pets_db', type='sql')`
38
+ */
38
39
private class StreamlitSqlConnection extends API:: CallNode {
39
40
StreamlitSqlConnection ( ) {
40
41
exists ( StringLiteral str , API:: CallNode n |
41
- str .getText ( ) = "sql"
42
- and
43
- n = API:: moduleImport ( "streamlit" ) .getMember ( "connection" ) .getACall ( )
44
- and
45
- DataFlow:: exprNode ( str ) .( DataFlow:: LocalSourceNode )
46
- .flowsTo ( [ n .getArg ( 1 ) , n .getArgByName ( "type" ) ] )
47
- and this = n
42
+ str .getText ( ) = "sql" and
43
+ n = API:: moduleImport ( "streamlit" ) .getMember ( "connection" ) .getACall ( ) and
44
+ DataFlow:: exprNode ( str )
45
+ .( DataFlow:: LocalSourceNode )
46
+ .flowsTo ( [ n .getArg ( 1 ) , n .getArgByName ( "type" ) ] ) and
47
+ this = n
48
48
)
49
-
50
49
}
51
50
}
51
+
52
52
/**
53
53
* The `query` call that can execute raw queries on a connection to a SQL database.
54
54
* https://docs.streamlit.io/develop/api-reference/connections/st.connection
55
55
*/
56
56
private class QueryMethodCall extends DataFlow:: CallCfgNode , SqlExecution:: Range {
57
-
58
57
QueryMethodCall ( ) {
59
- exists ( StreamlitSqlConnection s |
60
- this = s .getReturn ( ) .getMember ( "query" ) .getACall ( ) )
58
+ exists ( StreamlitSqlConnection s | this = s .getReturn ( ) .getMember ( "query" ) .getACall ( ) )
61
59
}
62
60
63
61
override DataFlow:: Node getSql ( ) { result in [ this .getArg ( 0 ) , this .getArgByName ( "sql" ) ] }
64
62
}
65
63
66
-
67
- /**
68
- * The Streamlit SQLConnection.connect() call, which returns a a new sqlalchemy.engine.Connection object.
69
- * Streamlit creates a connection to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
70
- */
71
- private class StreamlitSQLAlchemyConnection extends SqlAlchemy:: Connection:: InstanceSource {
72
- StreamlitSQLAlchemyConnection ( ) {
73
- exists ( StreamlitSqlConnection s |
74
- this = s .getReturn ( ) .getMember ( "connect" ) .getACall ( ) )
64
+ /**
65
+ * The Streamlit SQLConnection.connect() call, which returns a a new sqlalchemy.engine.Connection object.
66
+ * Streamlit creates a connection to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
67
+ */
68
+ private class StreamlitSqlAlchemyConnection extends SqlAlchemy:: Connection:: InstanceSource {
69
+ StreamlitSqlAlchemyConnection ( ) {
70
+ exists ( StreamlitSqlConnection s | this = s .getReturn ( ) .getMember ( "connect" ) .getACall ( ) )
75
71
}
76
72
}
77
73
78
- /**
79
- * The underlying SQLAlchemy Engine, accessed via `st.connection().engine`.
80
- * Streamlit creates an engine to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
81
- */
82
- private class StreamlitSqlAlchemyEngine extends SqlAlchemy:: Engine:: InstanceSource {
74
+ /**
75
+ * The underlying SQLAlchemy Engine, accessed via `st.connection().engine`.
76
+ * Streamlit creates an engine to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
77
+ */
78
+ private class StreamlitSqlAlchemyEngine extends SqlAlchemy:: Engine:: InstanceSource {
83
79
StreamlitSqlAlchemyEngine ( ) {
84
- exists ( StreamlitSqlConnection s |
85
- this = s .getReturn ( ) .getMember ( "engine" ) .asSource ( ) )
80
+ exists ( StreamlitSqlConnection s | this = s .getReturn ( ) .getMember ( "engine" ) .asSource ( ) )
86
81
}
87
82
}
88
83
89
- /**
90
- * The SQLAlchemy Session, accessed via `st.connection().session`.
91
- * Streamlit can create a session to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
92
- * For example, the modeling for `session` includes an `execute` method, which is used to execute raw SQL queries.
93
- * https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection#:~:text=SQLConnection.engine-,SQLConnection.session,-Streamlit%20Version
94
- */
84
+ /**
85
+ * The SQLAlchemy Session, accessed via `st.connection().session`.
86
+ * Streamlit can create a session to a SQL database basing off SQL Alchemy, so we can reuse the models that we already have.
87
+ * For example, the modeling for `session` includes an `execute` method, which is used to execute raw SQL queries.
88
+ * https://docs.streamlit.io/develop/api-reference/connections/st.connections.sqlconnection#:~:text=SQLConnection.engine-,SQLConnection.session,-Streamlit%20Version
89
+ */
95
90
private class StreamlitSqlSession extends SqlAlchemy:: Session:: InstanceSource {
96
91
StreamlitSqlSession ( ) {
97
- exists ( StreamlitSqlConnection s |
98
- this = s .getReturn ( ) .getMember ( "session" ) .asSource ( ) )
92
+ exists ( StreamlitSqlConnection s | this = s .getReturn ( ) .getMember ( "session" ) .asSource ( ) )
99
93
}
100
94
}
101
95
}
0 commit comments