verticapy.create_table#
- verticapy.create_table(table_name: str, dtype: dict, schema: str | None = None, temporary_table: bool = False, temporary_local_table: bool = True, 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.
- temporary_local_table: bool, optional
If set to True, a temporary local table is be created. The parameter ‘schema’ must be empty, otherwise this parameter is ignored.
- 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#
- bool
True if the table was successfully created, False otherwise.
Examples#
The
create_table
function offers multiple options.Let’s import the function.
from verticapy.sql import create_table
You can generate the SQL needed to create the table.
create_table( table_name = "employees", schema = "public", dtype = {"name": "VARCHAR(60)", "salary": "FLOAT"}, genSQL = True, ) Out[2]: 'CREATE TABLE "public"."employees"("name" VARCHAR(60), "salary" FLOAT);'
Or create the table.
create_table( table_name = "employees", schema = "public", dtype = {"name": "VARCHAR(60)", "salary": "FLOAT"}, ) Out[3]: True
The table can be utilized as a vDataFrame.
import verticapy as vp vp.vDataFrame("public.employees")
AbcnameVarchar(60)123salaryFloat(22)Rows: 0 | Columns: 2See also
create_schema()
: Creates a schema.