class parsons.CivisClient(db=None, api_key=None, **kwargs)[source]

Instantiate the Civis class.

api_key: str

The Civis api key.

db: str or int

The Civis Redshift database. Can be a database id or the name of the database.

**kwargs: args

Option settings for the client that are described in the documentation.


Civis class


The Civis API client. Utilize this attribute to access to lower level and more advanced methods which might not be surfaced in Parsons. A list of the methods can be found by reading the Civis API client documentation.

query(sql, preview_rows=10, polling_interval=None, hidden=True, wait=True)[source]

Execute a SQL statement as a Civis query.

Run a query that may return no results or where only a small preview is required. To execute a query that returns a large number of rows, see read_civis_sql().

sql: str

The SQL statement to execute.

preview_rows: int, optional

The maximum number of rows to return. No more than 100 rows can be returned at once.

polling_interval: int or float, optional

Number of seconds to wait between checks for query completion.

hidden: bool, optional

If True (the default), this job will not appear in the Civis UI.

wait: boolean

If True, will wait for query to finish executing before exiting the method.

Parsons Table

See Parsons Table for output options.

table_import(table_obj, table, max_errors=None, existing_table_rows='fail', diststyle=None, distkey=None, sortkey1=None, sortkey2=None, wait=True, **civisargs)[source]

Write the table to a Civis Redshift cluster. Additional key word arguments can passed to # noqa: E501

table_obj: obj

A Parsons Table object

table: str

The schema and table you want to upload to. E.g., ‘scratch.table’. Schemas or tablenames with periods must be double quoted, e.g. ‘scratch.”my.table”’.

api_key: str

Your Civis API key. If not given, the CIVIS_API_KEY environment variable will be used.

max_errors: int

The maximum number of rows with errors to remove from the import before failing.

existing_table_rows: str

The behaviour if a table with the requested name already exists. One of ‘fail’, ‘truncate’, ‘append’ or ‘drop’. Defaults to ‘fail’.

diststyle: str

The distribution style for the table. One of ‘even’, ‘all’ or ‘key’.

distkey: str

The column to use as the distkey for the table.

sortkey1: str

The column to use as the sortkey for the table.

sortkey2: str

The second column in a compound sortkey for the table.

wait: boolean

Wait for write job to complete before exiting method.