create_table

In [ ]:
create_table(table_name: str,
             dtype: dict,
             schema: str = "",
             temporary_table: bool = False,
             temporary_local_table: bool = True,
             genSQL: bool = False,
             raise_error: bool = False,)

Creates a new table using the input column names and data types.

Parameters

Name Type Optional Description
table_name
str
❌
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
✓
Schema name.
temporary_table
bool
✓
If set to True, a temporary table will be created.
temporary_local_table
bool
✓
If set to True, a temporary local table will be created. The parameter 'schema' must be empty, otherwise this parameter is ignored.
genSQL
bool
✓
If set to True, the SQL code for creating the final table will be generated but not executed.
raise_error
bool
✓
If the relation couldn't be created, raises the entire error.

Returns

bool : True if the table was successfully created, False otherwise.

Example

In [4]:
from verticapy.utilities import create_table

# Generates the SQL needed to create the Table
create_table(table_name = "employees",
             schema = "public",
             dtype = {"name": "VARCHAR(60)", "salary": "FLOAT"},
             genSQL = True)
Out[4]:
'CREATE TABLE "public"."employees"("name" VARCHAR(60), "salary" FLOAT);'
In [5]:
# Creates the table
create_table(table_name = "employees",
             schema = "public",
             dtype = {"name": "VARCHAR(60)", "salary": "FLOAT"},)
Out[5]:
True
In [6]:
%load_ext verticapy.sql
In [7]:
%sql SELECT * FROM public.employees;
Execution: 0.018s
Out[7]:
Abc
name
Varchar(60)
123
salary
Float
Rows: 0 | Columns: 2