vastorbit.create_table¶
- vastorbit.create_table(table_name: str, dtype: dict, schema: str | None = None, temporary_table: bool = False, genSQL: bool = False, raise_error: bool = False) bool¶
Creates a new table using the input columns’ names and data types.
- Parameters:
table_name (str) – The final table name.
dtype (dict) – Dictionary of the user types. Each key represents a column name and each value represents its data type. Example: {“age”: “int”, “name”: “varchar”}
schema (str, optional) – Schema name.
temporary_table (bool, optional) – If set to True, a temporary table is created.
genSQL (bool, optional) – If set to True, the SQL code for creating the final table is generated but not executed.
raise_error (bool, optional) – If the relation couldn’t be created, raises the entire error.
- Returns:
True if the table was successfully created, False otherwise.
- Return type:
bool
Examples
The
create_tablefunction offers multiple options.Let’s import the function.
from vastorbit.sql import create_table
You can generate the SQL needed to create the table.
create_table( table_name = "employees", dtype = {"name": "VARCHAR(60)", "salary": "REAL"}, genSQL = True, )
Or create the table.
create_table( table_name = "employees", dtype = {"name": "VARCHAR(60)", "salary": "REAL"}, )
The table can be utilized as a VastFrame.
import vastorbit as vo vo.VastFrame("employees")
AbcnameVarchar(60)123salaryRealRows: 0 | Columns: 2See also
create_schema(): Creates a schema.