sqlalchemy : executing raw sql with parameter bindings sqlalchemy : executing raw sql with parameter bindings python python

sqlalchemy : executing raw sql with parameter bindings


You need to get the connection object, call execute() on it and pass query parameters as keyword arguments:

from alembic import opfrom sqlalchemy.sql import textconn = op.get_bind()conn.execute(    text(        """            insert into field_tags             (id, field_id, code, description)             values             (1, 'zasz', :code , :description)        """    ),     **t)

Also see: How to execute raw SQL in SQLAlchemy-flask app.