I'm canceling this thread. It belongs in the Python list. Sorry!
V
On Fri, May 21, 2010 at 1:24 PM, Victor Subervi <[email protected]>wrote:
> Hi;
> When I try to execute this code from my Python script, I get this error:
>
> Traceback (most recent call last):
> File
> "/var/www/html/creative.vi/clients/sea-flight/reservations/create_edit_bags3.py",
> line 38, in ?
>
> create_edit_bags3()
> File
> "/var/www/html/creative.vi/clients/sea-flight/reservations/create_edit_bags3.py",
> line 32, in create_edit_bags3
>
> cursor.execute('insert into Baggage values (Null, %s, %s, %s, %s)',
> (flight_id, customer_id, weight, ticket_no))
> File "/usr/lib64/python2.4/site-packages/MySQLdb/cursors.py", line 163, in
> execute
>
> self.errorhandler(self, exc, value)
> File "/usr/lib64/python2.4/site-packages/MySQLdb/connections.py", line 35,
> in defaulterrorhandler
> raise errorclass, errorvalue
> OperationalError: (1452, 'Cannot add or update a child row: a foreign key
> constraint fails (`seaflight/Baggage`, CONSTRAINT `Baggage_ibfk_2` FOREIGN
> KEY (`customer_id`) REFERENCES `Customers` (`id`))')
>
> However, when I try from the MySQL prompt after duly printing it out from
> the code, it works. Why?
> TIA,
> Victor
>