https://medium.com/analytics-and-data/jinja-the-sql-way-of-the-ninja-9a64fc815564nn nnJinja Templates in Data EngineeringnHow they can be used in data engineeringnJinja template can help in implementing Dynamic SQL. Dynamic SQL helps generalize the SQL code that is being created. In Python, there are alternative to Jinja templates such as building string statements to achieve this goal. Still, there are a few advantages of using Jinja templates over built-in string interpolation and standard SQL queries:nnIncreased legibility: Having the code used for the generation of the SQL query in a template, increases legibility compared to building string statements. It might howerver, require different functions to generate part of the SQL statements. With a template, these different components are rendered inline based on the initial variables input. In a complex query situation, the use of loops and other types of abstraction with Jinja can increase the legibility of the queries over typing/copy-pasting multiple times over like you would do in a normal SQL statement.nnEasily importable: The template can easily be imported as a single file that, once rendered, will provide a SQL query to run. It allows for clear separation of code in an MVC like manners.nnWeb developer onboarding: Since the template style is heavily used in web development, using the same pattern to build Dynamic SQL statements can make it easier to onboard those with a background of web development to the project.nn
