Installation
The Kinetica Dialect for SQLAlchemy can be installed from PyPI usingpip:
Connecting
The standard SQLAlchemycreate_engine call can be used to connect to a
Kinetica database instance.
For HTTPS-based installations, the bypass_ssl_cert_check option can be used
to bypass any server certificate validation.
Managing Connections
SQLAlchemy connections can either be automatically or manually managed. When manually managed, connections must be explicitly closed after use.Data Types
All Kinetica data types are available to be used in SQLAlchemy through either native SQLAlchemy types or Kinetica custom dialect types.Number
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
BOOLEAN | sqlalchemy.Boolean |
TINYINT | sqlalchemy_kinetica.kinetica_types.TINYINT |
SMALLINT | sqlalchemy_kinetica.kinetica_types.SMALLINT |
INTEGER | sqlalchemy.Integer |
BIGINT | sqlalchemy.BIGINT |
UNSIGNED BIGINT | sqlalchemy_kinetica.kinetica_types.UnsignedBigInteger |
REAL | sqlalchemy.REAL |
DOUBLE | sqlalchemy.DOUBLE |
DECIMAL(P,S) | sqlalchemy_kinetica.kinetica_types.DECIMAL |
String
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
VARCHAR | sqlalchemy.VARCHAR |
IPV4 | sqlalchemy_kinetica.kinetica_types.IPV4 |
UUID | sqlalchemy.UUID |
JSON | sqlalchemy_kinetica.kinetica_types.JSON |
Date/Time
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
DATE | sqlalchemy.DATE |
DATETIME | sqlalchemy.DATETIME |
TIME | sqlalchemy.TIME |
TIMESTAMP | sqlalchemy.TIMESTAMP |
Binary
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
BLOB | sqlalchemy_kinetica.kinetica_types.BLOB |
Geospatial
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
GEOMETRY | sqlalchemy_kinetica.kinetica_types.GEOMETRY |
BLOB(WKT) | sqlalchemy_kinetica.kinetica_types.BlobWKT |
Composite
| Kinetica Data Type | SQLAlchemy Type Class |
|---|---|
BOOLEAN[N] | sqlalchemy.ARRAY, sqlalchemy.Boolean |
INTEGER[N] | sqlalchemy.ARRAY, sqlalchemy.Integer |
BIGINT[N] | sqlalchemy.ARRAY, sqlalchemy.BIGINT |
VECTOR(N) | sqlalchemy_kinetica.kinetica_types.VECTOR |
REAL[N] | sqlalchemy.ARRAY, sqlalchemy.REAL |
DOUBLE[N] | sqlalchemy.ARRAY, sqlalchemy.DOUBLE |
VARCHAR[N] | sqlalchemy.ARRAY, sqlalchemy.VARCHAR |
Creating Tables
The full set of Kinetica table operations, table options, and column types are available through the execution of Kinetica SQL as string literals. A large portion of the Kinetica table feature set is available via SQLAlchemy objects and the Kinetica dialect.Column Types
The following demonstrates creating a table with various column types using a SQL literal as compared to using SQLAlchemy objects:Replicated Tables
The following demonstrates creating a replicated table using a SQL literal as compared to using SQLAlchemy objects:Sharded Tables with Options
The following demonstrates creating a sharded table with a variety of table options applied, using a SQL literal as compared to using SQLAlchemy objects:CREATE TABLE…AS
CREATE TABLE … AS is supported in both native SQL and in the Kinetica Dialect for SQLAlchemy as the following examples show:External Tables
CREATE EXTERNAL TABLE is supported in both native SQL and in the Kinetica Dialect for SQLAlchemy as the following examples show:Managing Data
The full set of Kinetica data manipulation operations are available through both the execution of Kinetica SQL as string literals as well as via SQLAlchemy objects and the Kinetica dialect.Inserting Data as Values
The following demonstrates inserting data as raw values using a SQL literal as compared to using SQLAlchemy objects:Inserting Data from a Query
The following demonstrates inserting data from a query using a SQL literal as compared to using SQLAlchemy objects:Inserting Data using a CTE
The following demonstrates inserting data with a CTE using a SQL literal as compared to using SQLAlchemy objects:Updating Data with Constants
The following demonstrates updating data with raw values using a SQL literal as compared to using SQLAlchemy objects:Updating Data with Subquery Filter
The following demonstrates updating data with a subquery filter (subquery in theWHERE clause) using a SQL literal as
compared to using SQLAlchemy objects:
Updating Data with Subquery Assignment
The following demonstrates updating data with a subquery assignment (subquery in theSET clause) using a SQL literal as
compared to using SQLAlchemy objects:
Updating Data with Join
The following demonstrates updating data with a join using a SQL literal as compared to using SQLAlchemy objects:Deleting Data with Constants
The following demonstrates deleting data with raw values using a SQL literal as compared to using SQLAlchemy objects:Deleting Data with Subquery Filter
The following demonstrates deleting data with a subquery filter (subquery in theWHERE clause) using a SQL literal as
compared to using SQLAlchemy objects: