Loading...

vastorbit.core.tablesample.base.TableSample.read_sql

classmethod TableSample.read_sql(query: str | StringSQL, title: str | None = None, max_columns: int = -1, _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.

Returns:

Result of the query.

Return type:

TableSample

Examples

Let’s import the TableSample object:

from vastorbit 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.
)
123
age
Integer
...
Abc
city
Varchar(5)
130...Sofia
Rows: 1-1 | Columns: 3

See also

VastFrame : Main vastorbit dataset object.