When I try to load a MySQL DB on pythonanywhere from a CSV generated from a
SQLite DB using (literally) the same schema, I get the following:
>>> db.import_from_csv_file(open("trials_export.csv","rb"))
Traceback (most recent call last): File "<console>",
line 1, in <module> File
"/home/ukitms/web2py/gluon/packages/dal/pydal/base.py", line 1116, in
import_from_csv_file *args, **kwargs) File
"/home/ukitms/web2py/gluon/packages/dal/pydal/objects.py", line 978, in
import_from_csv_file new_id = self.insert(**dict(items)) File
"/home/ukitms/web2py/gluon/packages/dal/pydal/objects.py", line 726, in
insert ret = self._db._adapter.insert(self, self._listify(fields)) File
"/home/ukitms/web2py/gluon/packages/dal/pydal/adapters/base.py", line 746,
in insert raise eIntegrityError: (1452, 'Cannot add or update a child
row: a foreign key constraint fails (`ukitms$trials`.`t_classlevel`,
CONSTRAINT `t_classlevel_ibfk_1` FOREIGN KEY (`f_Trial`) REFERENCES
`t_trial` (`id`) ON DELETE CASCADE)')>>>
The relevant part of the schema is:
db.define_table( 't_classlevel',
Field( 'f_Trial', 'reference t_trial' ),
Table `t_trial` does appear in the CSV before `t_classlevel`; I checked
that the `f_Trial` field in every record has a corresponding `t_trial`
record.
Is there some way to identify what line of the CSV is causing this? How
could this constraint be violated if the values all correspond to valid
records?
- Scott
--
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].
For more options, visit https://groups.google.com/d/optout.