%sqlrender
#
New in version 0.4.3.
%sqlrender
helps you compose large SQL queries.
%load_ext sql
%sql sqlite:///
%%sql --save writers_fav --no-execute
SELECT *
FROM authors
WHERE genre = 'non-fiction'
* sqlite:///
Skipping execution...
%%sql --save writers_fav_modern --no-execute --with writers_fav
SELECT * FROM writers_fav
WHERE born >= 1970
* sqlite:///
Skipping execution...
query = %sqlrender writers_fav_modern --with writers_fav_modern
print(query)
WITH writers_fav AS (SELECT * FROM authors WHERE genre = 'non-fiction') SELECT * FROM writers_fav WHERE born >= 1970