Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

amazon redshift

>>> import sqlalchemy as sa
>>> from sqlalchemy.schema import CreateTable
>>> engine = sa.create_engine('redshift+psycopg2://example')
>>> metadata = sa.MetaData()
>>> user = sa.Table(
...     'user',
...     metadata,
...     sa.Column('id', sa.Integer, primary_key=True),
...     sa.Column('name', sa.String),
...     redshift_diststyle='KEY',
...     redshift_distkey='id',
...     redshift_interleaved_sortkey=['id', 'name'],
... )
>>> print(CreateTable(user).compile(engine))

CREATE TABLE "user" (
    id INTEGER NOT NULL,
    name VARCHAR,
    PRIMARY KEY (id)
) DISTSTYLE KEY DISTKEY (id) INTERLEAVED SORTKEY (id, name)
Comment

PREVIOUS NEXT
Code Example
Python :: multiple line string 
Python :: adding numbers in python 
Python :: how to add a 2d array to one dataframe colum 
Python :: get date only from datetimefiel django 
Python :: how to write user input to a file in python 
Python :: delete content of table django 
Python :: import user model 
Python :: python capitalize 
Python :: Use len with list 
Python :: conv2d default stride 
Python :: reverse a list in python 
Python :: program to replace lower-case characters with upper-case and vice versa in python 
Python :: Python List clear() 
Python :: set remove in python 
Python :: python string contains substring ignore case 
Python :: py array contains 
Python :: armstrong number in python 
Python :: prime numbers upto n in python 
Python :: python print bytes 
Python :: convert exception to string python 
Python :: PermissionError: [Errno 13] Permission denied on flask 
Python :: how to make loops in python 
Python :: add bootstrap to django form 
Python :: Removing Elements from Python Dictionary Using popitem() method 
Python :: determine how 2 string si equal py 
Python :: numpy add 
Python :: any all in python 
Python :: cache-control no cache django 
Python :: tf dataset 
Python :: random forest algorithm 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =