hello i have this table

db.define_table('pedidos',
    Field('amostra',db.amostras),
    Field('destino'),
    Field('estante','integer'),
    Field('x','integer'),
    Field('y','integer'),
    Field('estante1',compute =lambda
r:"_E_"+str(r['estante'])+str(r['x'])+str(r['y'])),
    Field('created','datetime',default=request.now),
    Field('sit',default='danger'),
    Field('creator',db.auth_user,default=auth.user_id),
)




when i do this

db.pedidos.update_or_insert((db.pedidos.amostra==amostra.n) &
(db.pedidos.destino=='end'),amostra=amostra.n,destino='end',estante=amostra.estante,x=amostra.x,y=amostra.y,creator=6,sit='danger')

i get the error




<class 'sqlite3.IntegrityError'> foreign key constraint
failedVersãoweb2py™Version
2.9.5-stable+timestamp.2014.03.16.02.35.39PythonPython 2.7.9:
/usr/local/bin/python (prefix: /usr/local)Traceback

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File "/home/ramstein74/webapps/2py/web2py/gluon/restricted.py", line
220, in restricted
    exec ccode in environment
  File 
"/home/ramstein74/webapps/2py/web2py/applications/lab/controllers/default.py"
<https://empre.cires.pt/admin/default/edit/lab/controllers/default.py>,
line 510, in <module>
  File "/home/ramstein74/webapps/2py/web2py/gluon/globals.py", line
385, in <lambda>
    self._caller = lambda f: f()
  File 
"/home/ramstein74/webapps/2py/web2py/applications/lab/controllers/default.py"
<https://empre.cires.pt/admin/default/edit/lab/controllers/default.py>,
line 62, in deleteAmostrasAntigas
    db.pedidos.update_or_insert((db.pedidos.amostra==amostra.n) &
(db.pedidos.destino=='end'),amostra=amostra.n,destino='end',estante=amostra.estante,x=amostra.x,y=amostra.y,creator=6,sit='danger')
  File "/home/ramstein74/webapps/2py/web2py/gluon/dal.py", line 9182,
in update_or_insert
    newid = self.insert(**values)
  File "/home/ramstein74/webapps/2py/web2py/gluon/dal.py", line 9114, in insert
    ret =  self._db._adapter.insert(self, self._listify(fields))
  File "/home/ramstein74/webapps/2py/web2py/gluon/dal.py", line 1360, in insert
    raise e
IntegrityError: foreign key constraint failed




Help please


:)

-- 
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/d/optout.

Reply via email to