Skip to content

Commit

Permalink
docs(examples): add example and see also ref for ibis.to_sql
Browse files Browse the repository at this point in the history
  • Loading branch information
IndexSeek authored and cpcloud committed Nov 23, 2024
1 parent e69348b commit 9877766
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ibis/expr/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,30 @@ def to_sql(
str
Formatted SQL string
Examples
--------
>>> import ibis
>>> t = ibis.table({"a": "int", "b": "int"}, name="t")
>>> expr = t.mutate(c=t.a + t.b)
>>> ibis.to_sql(expr)
SELECT
"t0"."a",
"t0"."b",
"t0"."a" + "t0"."b" AS "c"
FROM "t" AS "t0"
You can also specify the SQL dialect to use for compilation:
>>> ibis.to_sql(expr, dialect="mysql")
SELECT
`t0`.`a`,
`t0`.`b`,
`t0`.`a` + `t0`.`b` AS `c`
FROM `t` AS `t0`
See Also
--------
[`Table.compile()`](./expression-tables.qmd#ibis.expr.types.relations.Table.compile)
"""
import ibis.backends.sql.compilers as sc

Expand Down

0 comments on commit 9877766

Please sign in to comment.