Peter Hoffmann

Python SQLAlchemy Exasol 0.9.1 With Distribute By Support

sqlalchemy exasol 0.9.1 has been released. This release adds support for data distribution across cluster nodes using the distribute by statement.

from sqlalchemy import create_engine, MetaData, Table, Column, Integer
from sqlalchemy_exasol.constraints import DistributeByConstraint
from sqlalchemy.schema import CreateTable

engine = create_engine("exa+pyodbc://user:pw@host/")

md = MetaData(bind=engine)

t = Table('t', md,
           Column('a', Integer),
           Column('b', Integer),
           Column('c', Integer),
           DistributeByConstraint('a', 'b')
        )

print CreateTable(t).compile(engine)

This produces the following CREATE TABLE statement:

    CREATE TABLE t (
        a INTEGER,
        b INTEGER,
        c INTEGER,
        DISTRIBUTE BY a,b
    )