Loading Data

You can load data into your Vertica Analytic Database using the Vertica Python Client and COPY FROM STDIN. In this example we will load data into a table called foo.

Setup

Create a database connection, and open a cursor:

>>> import vertica_db_client
>>> db = vertica_db_client.connect("host=bar_host database=db_name port=5433 user=dbadmin")
>>> cur = db.cursor()

Open a file:

>>> f = open("./data/verticaData.txt", "r")

Assign your file to STDIN:

>>> cur.stdin = f

Load the data using COPY FROM STDIN:

>>> cur.execute("COPY foo FROM STDIN")