Hello!
below is my script
class User(Base):
__table_args__ = {"schema":"shm"}
__tablename__ = "users"
__table_args__ = (
        PrimaryKeyConstraint('date', 'country', 'product', 'info'),
        {"schema":"royalty_input"}
    )
date = Column('date', Date)
pipeline_versions = Column('pipeline_versions', ARRAY(TEXT))
country = Column('country', String(2))
product = Column('product', TEXT)
info = Column('info', JSONB, nullable=False)

with open("config.json", 'r') as infile:
config = json.load(infile)
print config['database']

db = create_engine(config['database'], echo=True)
Session = sessionmaker(bind=db)
session = Session()

#users = db.execute('SELECT * FROM royalty_input.registered_users limit 
1');#session.query(User).first()
data = 
session.query(User).filter(User.reporting_country=="DE").filter(User.date>='2018-09-01',User.date<='2018-09-30').all()

Its giving below Error:

raceback (most recent call last):

  File "app.py", line 39, in <module>

    data = 
session.query(User).filter(User.reporting_country=="DE").filter(User.date>='2018-09-01',User.date<='2018-09-30').all()

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/orm/query.py",
 
line 2843, in all

    return list(self)

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
 
line 98, in instances

    util.raise_from_cause(err)

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/util/compat.py",
 
line 265, in raise_from_cause

    reraise(type(exception), exception, tb=exc_tb, cause=cause)

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
 
line 79, in instances

    rows = [proc(row) for row in fetch]

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/orm/loading.py",
 
line 458, in _instance

    instance = session_identity_map.get(identitykey)

  File 
"/Users/vipinm/python_script/venv/lib/python2.7/site-packages/sqlalchemy/orm/identity.py",
 
line 162, in get

    if key not in self._dict:

TypeError: unhashable type: 'dict'

It works if I remove 'info' from the primary key list


Any help appreciated!

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to