Hello,
I've got a table like this:
db._common_fields.append(auth.signature)
db.define_table('locations',
Field('title', 'string'),
Field('capacity', 'integer'),
Field('celcat_code', 'string'),
Field('is_external', 'boolean', default=False),
format = lambda row: f"{row.title}")
I'm trying to populate that with legacy data using:
filepath = os.path.join(request.folder, 'static', 'data',
'teaching_staff.csv')
with open(filepath, encoding="utf8") as csvfile:
db.teaching_staff.import_from_csv_file(csvfile)
And I get a ticket:
IntegrityError(FOREIGN KEY constraint failed)
I think what is going on is that - because no-one is logged in when that
import is run - the `auth.signature` fields are None and so that is the
constraint that is failing. Is there a canonical way to handle this? I had
a quick look at the code and couldn't see an option for inserting default
values. I can write a loop and add default values myself to individual
record inserts but is there a standard way?
Many thanks,
David
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/5ff89449-5883-4310-af1b-d419949acb84o%40googlegroups.com.