Loading...

verticapy.core.tablesample.base.TableSample.read_sql

classmethod TableSample.read_sql(query: str | StringSQL, title: str | None = None, max_columns: int = -1, sql_push_ext: bool = False, symbol: str = '$', _clean_query: bool = True, _formats: list[str] | None = None) → TableSample

Returns the result of a SQL query as a TableSample object.

Parameters

query: str, optional

SQL Query.

title: str, optional

Query title when the query is displayed.

max_columns: int, optional

Maximum number of columns to display.

sql_push_ext: bool, optional

If set to True, the entire query is pushed to the external table. This can increase performance but might increase the error rate. For instance, some DBs might not support the same SQL as Vertica.

symbol: str, optional

Symbol used to identify the external connection. One of the following: "$", "€", "£", "%", "@", "&", "§", "%", "?", "!"

Returns

TableSample

Result of the query.

Examples

Let’s import the TableSample object:

from verticapy import TableSample

Let’s build an example object.

# SQL query.
sql = "SELECT 30 AS age, 'Vanesa' AS name, 'Sofia' AS city;"

# creating the object from the SQL query.
tb = TableSample.read_sql(
    query = sql,
    title = 'Building a TableSample for testing',
    max_columns = 2, # Maximum number of columns to display.
    sql_push_ext = False, # No external DB.
)

Connected Successfully!
123
age
Integer
...
Abc
city
Varchar(5)
130...Sofia
Rows: 1-1 | Columns: 3

See also

vDataFrame : Main VerticaPy dataset object.