[web2py] Re: Table field isn't set to be unique, but results in error title is not unique

2013-09-12 Thread rochacbruno
Your title field was unique in the past, so you changed it to non-unique 
in model definition?

If so, the sad news is that SQLite does not support the ALTER TABLE 
command for columns, it means once defined, the column attributes cant be 
changed.

The only solution I know is to install an app called SQLiteManager then 
right click and edit the table properties there, that program does that by 
cloning in to a temporary table and do some renaming tricks to get it 
working.

or, you can backup/dump your data in some json or csv, delete the 
database and create it again, then populate the data back.

-- 

*Bruno Rocha - @rochacbruno*
http://github.com/rochacbruno
http://rochacbruno.com.br
http://pythonhub.com

On Thursday, September 12, 2013 4:50:17 AM UTC-3, Andreas Wienes wrote:

 Hi,

 I got a problem with one of my database tables. The field 'title' isn't 
 set to be unique. But inserting a row using filter_fields() ends with error 
 title is not unique.

 db.define_table('task',
Field('title', unique=False),
Field('description', 'text', notnull=True),
  format='%(title)s')

 db.define_table('step',
Field('title'),
Field('description', 'text', notnull=True),
format='%(title)s')

 db.task.insert(**db.task._filter_fields(step))

 class 'sqlite3.IntegrityError' column title is not unique

 Any help would be great!

 - Andreas


-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


[web2py] Re: Table field isn't set to be unique, but results in error title is not unique

2013-09-12 Thread Andreas Wienes
Thanks a lot Bruno. That worked for me.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
web2py-users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.