Loading...

verticapy.core.tablesample.base.TableSample.to_sql#

TableSample.to_sql() str#

Generates the SQL query associated to the TableSample.

Returns#

str

SQL query associated to the TableSample.

Examples#

Let’s import the TableSample object:

from verticapy import TableSample

Let’s build an example object.

# dict with all the data.
d = {
    "customer_ID": [0, 1, 2, 3],
    "age": [40, 30, 22, 55],
    "name": ['Roger', 'Maria', 'Alisia', 'Costi'],
}


# creating the object.
tb = TableSample(d)
customer_ID
age
name
1040Roger
2130Maria
3222Alisia
4355Costi
Rows: 1-4 | Columns: 3

Let’s use the function.

print(tb.to_sql())
(SELECT 0 AS "customer_ID", 40 AS "age", 'Roger' AS "name") UNION ALL (SELECT 1 AS "customer_ID", 30 AS "age", 'Maria' AS "name") UNION ALL (SELECT 2 AS "customer_ID", 22 AS "age", 'Alisia' AS "name") UNION ALL (SELECT 3 AS "customer_ID", 55 AS "age", 'Costi' AS "name")

See also

TableSample.to_vdf() : Converts the TableSample to a vDataFrame.