Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pony.orm import *
- db = Database()
- class Product(db.Entity):
- id = PrimaryKey(int, auto=True)
- name = Required(str)
- stars = Optional(IntArray)
- tags = Optional(StrArray)
- db.bind('sqlite', ':memory:')
- db.generate_mapping(create_tables=True)
- with db_session:
- product = Product(name='abc', stars=[1, 2, 3], tags = ['qwe'])
- tags = select(p.stars[:3] for p in Product)[:]#Ok
- print(tags)
- end = 3
- tags = select(p.stars[:end] for p in Product)[:]#TypeError: Array indices should be type of int
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement