I'm writing a query code in controller:
books=db(db.book.lib_name=="My-Library-Name").select(db.book.title, db.book.ISBN, orderby=db.book.title)
but I keep getting this error:
<type 'exceptions.ValueError'> invalid literal for long() with base 10: "My-Library-Name"
This is my DAL database(I am using postgresql as my database driver):
db = DAL('postgres://myUsername:myPassword@localhost/libman',pool_size=0)
db.define_table('library',
Field('lib_name', ondelete='CASCADE', unique=True),
Field('address', length=20),
primarykey=['lib_name'])
db.define_table('book',
Field('ISBN', unique=True, ondelete='CASCADE'),
Field('lib_name', 'reference library'),
Field('pic', 'upload'),
Field('title', length=100),
Field('publisher_lname', length=50),
Field('publisher_fname', length=50),
Field('no_of_copies', 'integer'),
Field('available_copies', 'integer'),
Field('description', length=255),
primarykey=['ISBN'])
Thanks in Advance for the respond
lib-name is a foreign key, so it is not a valid query. Query could be based on db.book.ISBN instead.
On the other hand I suggest to change your model to:
Since primarykey is intended to connect to legacy DB. Dont know if this is your case