Comments (2)
This feels kinda risky from a security perspective. Could you use SqlAlchemy to dump the SA query to a SQL string instead?
from airflow.
Can you explain which kind of security issues you see?
Actually yes, I finally found a way to dump the query as a SQL string. However, it requires that you know which kind of backend will execute the query.
import sqlalchemy as sa
stmt = sa.select(sa.bindparam("foo"))
from sqlalchemy.dialects import postgresql, sqlite, mysql
print("str: ", str(stmt))
print("compile(): ", str(stmt.compile()))
print("compile(postgresql): ", str(stmt.compile(dialect=postgresql.dialect())))
print("compile(mysql): ", str(stmt.compile(dialect=mysql.dialect())))
print("compile(sqlite): ", str(stmt.compile(dialect=sqlite.dialect())))
Will output:
str: SELECT :foo AS anon_1
compile(): SELECT :foo AS anon_1
compile(postgresql): SELECT %(foo)s AS anon_1
compile(mysql): SELECT %s AS anon_1
compile(sqlite): SELECT ? AS anon_1
As you can see, depending on your backend, the generated string is not the same. But I often use a sqlite backend during my dev/test process, while my production DB use Postgres. So it could be nice to abstract such kind of implementation, as long as your Airflow connection is a valid DbApi connection.
from airflow.
Related Issues (20)
- celery_executor.py remove_running got an unexpected keyword HOT 6
- Airflow 2.9.1 : AirflowContextDeprecationWarning: Accessing 'yesterday_ds_nodash' from the template is deprecated and will be removed in a future version. HOT 2
- EmrServerlessStartJobOperator causes dag load failure when using XComArg HOT 4
- Connection edit page says "Changed Row" even if field changes were not saved HOT 1
- Tasks Stuck at Scheduled State HOT 9
- local installation problem HOT 2
- Status of testing Providers that were prepared on June 07, 2024 HOT 14
- Operator `SQLExecuteQueryOperator` not logging `RAISE NOTICE` statements in PostgreSQL functions HOT 10
- EKS Overrides for AWS Batch submit_job HOT 1
- Rendered Template Fields missing for some tasks HOT 2
- dag callbacks not called on SSHOperator (base operator?) HOT 13
- Password autocompletion set to off on login page HOT 2
- Amazon Provider v8.23.0 `importlib_metadata` module import error HOT 3
- BranchDateTimeOperator Does Not Work According to DAG Timezone HOT 3
- DAG params ordering goes by key string length for some backends HOT 3
- Integrate Snowflake Notebook Scheduling with Apache Airflow HOT 6
- Webserver logs not showing failed login attempts HOT 3
- SambaHook unable to join path when Share attribute is None
- Codecov is not in sync and shows inaccurate coverage HOT 4
- Google provider : Unnecessary imports for CloudSQL operators HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from airflow.