binarymatt / redshift_sqlalchemy

Amazon Redshift SQLAlchemy Dialect
MIT License
48 stars 21 forks source link

Cant specify table args: redshift_distkey, redshift_sortkey #18

Closed haleemur closed 10 years ago

haleemur commented 10 years ago

I tried creating a table using the following code

from sqlalchemy import Column, Integer, String, DateTime, Table, MetaData

user = Table('users', MetaData(bind=None),
    Column('id', Integer, primary_key=True, autoincrement=False),
    Column('name', String(30)),
    Column('email',String(50)),
    Column('created_at', DateTime),
    redshift_distkey='id',
    redshift_sortkey=['id', 'DateTime'])

and it gave me this error:

Traceback (most recent call last):
  File "<stdin>", line 7, in <module>
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/schema.py", line 354, in __new__
    table._init(name, metadata, *args, **kw)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/schema.py", line 421, in _init
    self._extra_kwargs(**kwargs)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/schema.py", line 500, in _extra_kwargs
    self._validate_dialect_kwargs(kwargs)
  File "/usr/local/lib/python3.4/dist-packages/sqlalchemy/sql/base.py", line 302, in _validate_dialect_kwargs
    dialect_name, self.__class__
sqlalchemy.exc.ArgumentError: Argument 'redshift_distkey' is not accepted by dialect 'redshift' on behalf of <class 'sqlalchemy.sql.schema.Table'>
haleemur commented 10 years ago

ahh bugger.

I installed the package using pip for python 3.3, and the file dialect.py was missing the class RedShiftDDLCompiler.

Then, I installed directly from github, and everything seems to be working fine. Could you please update the package on pypi for python3+.

If there's any way I can help, let me know

Thanks,

mikepii commented 9 years ago

I had the the first issue in Python 2.7 as well. Using the repo master got me past that issue