insert_into¶
In [ ]:
insert_into(table_name: str,
data: list,
schema: str = "",
column_names: list = [],
copy: bool = True,
genSQL: bool = False,)
Inserts the dataset into an existing Vertica table.
Parameters¶
Name | Type | Optional | Description |
---|---|---|---|
table_name | str | ❌ | Name of the table to insert into. |
data | list | ❌ | The data to ingest. |
schema | str | ✓ | Schema name. |
column_names | list | ✓ | Name of the column(s) to insert into. |
copy | bool | ✓ | If set to True, the batch insert is converted to a COPY statement with prepared statements. Otherwise, the INSERTs are performed sequentially. |
genSQL | bool | ✓ | If set to True, the SQL code that would be used to insert the data is generated, but not executed. |
Returns¶
int : The number of rows ingested.
Example¶
In [28]:
from verticapy.datasets import load_iris
iris = load_iris()
iris
Out[28]:
In [9]:
from verticapy.utilities import insert_into
# copy left as default (True): one copy
insert_into(table_name = "iris",
schema = "public",
data = [[3.3, 4.5, 5.6, 7.8, "Iris-setosa"],
[4.3, 4.7, 9.6, 1.8, "Iris-virginica"]],)
Out[9]:
In [10]:
# copy set to False: multiple inserts
insert_into(table_name = "iris",
schema = "public",
data = [[3.3, 4.5, 5.6, 7.8, "Iris-setosa"],
[4.3, 4.7, 9.6, 1.8, "Iris-virginica"]],
copy=False,)
Out[10]:
In [11]:
# genSQL set to True: SQL for inserting data is generated, but not executed
# copy set to False: multiple inserts
insert_into(table_name = "iris",
schema = "public",
data = [[3.3, 4.5, 5.6, 7.8, "Iris-setosa"],
[4.3, 4.7, 9.6, 1.8, "Iris-virginica"]],
genSQL=True,)
Out[11]: