Re: [web2py] Re: FOREIGN KEY constraint failed

2017-07-18 Thread Santiago Cartasegna
Glad that my idea helped!

2017-07-18 6:20 GMT-03:00 mostwanted :

> I was able o solve the problem, when i was creating the tables i copied
> and pasted a code for the '*governmetFormPages' *table but to correct the
> error i had to delete the table and type its code word for word, that
> solved my problem. thanks for the input guys. Santiago Cartasegna  was
> right.
>
> On Sunday, July 2, 2017 at 10:37:22 AM UTC+2, mostwanted wrote:
>>
>> Hi guys, i need help, i'm pulling my hairs out over here, i have a
>> website where when i'm trying to record an entry i get an error:
>>  FOREIGN KEY constraint failed
>>
>>
>> I have been able to create 2 forms but other attempts to create more
>> forms fail!!
>>
>>
>> These are my tables;
>>
>>
>> db.define_table('government',
>> Field('govName', requires=IS_NOT_EMPTY()),
>> Field('tel', requires=IS_NOT_EMPTY()),
>> Field('email', requires=IS_NOT_EMPTY()),
>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>
>>
>> db.define_table('governmenttForm',
>> Field('formImage', 'upload'),
>> Field('filledformImage', 'upload'),
>> Field('formName',requires=IS_NOT_EMPTY()),
>> Field('governmentName', 'reference government'),
>> format='%(formName)s',migrate=False,fake_migrate=True)
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()),
>> Field('formName', 'reference
>> govmntForm'),migrate=False,fake_migrate=True)
>>
>>
>> I am able to create a form for the governmentForm table but when i try to
>> load up the pages for governmentFormPages table i get the error
>>  FOREIGN KEY constraint failed
>>
>>
>> Below is the stack
>> Error ticket for "formulator" Ticket ID
>>
>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>  FOREIGN KEY constraint failed Version
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> ,
>>  line 703, in 
>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> ,
>>  line 151, in insert
>> if form.accepts(request.vars, session):
>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>> self.vars.id = self.table.insert(**fields)
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 726, in insert
>> ret = self._db._adapter.insert(self, self._listify(fields))
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 746, in insert
>> raise e
>> IntegrityError: FOREIGN KEY constraint failed
>>
>>
>> Please help me, i dont know what to do, i have tried to look for
>> solutions online but i just dont understand them, may someone please give
>> me light on what i'm doing wrong.
>>
> --
> 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 a topic in the
> Google Groups "web2py-users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/web2py/CPmr9UHWvOA/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Santiago Cartasegna.-

-- 
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.


[web2py] Re: FOREIGN KEY constraint failed

2017-07-18 Thread mostwanted
I was able o solve the problem, when i was creating the tables i copied and 
pasted a code for the '*governmetFormPages' *table but to correct the error 
i had to delete the table and type its code word for word, that solved my 
problem. thanks for the input guys. Santiago Cartasegna  was right.

On Sunday, July 2, 2017 at 10:37:22 AM UTC+2, mostwanted wrote:
>
> Hi guys, i need help, i'm pulling my hairs out over here, i have a website 
> where when i'm trying to record an entry i get an error:
>  FOREIGN KEY constraint failed
>
>
> I have been able to create 2 forms but other attempts to create more forms 
> fail!!
>
>
> These are my tables;
>
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table('governmenttForm',
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> I am able to create a form for the governmentForm table but when i try to 
> load up the pages for governmentFormPages table i get the error
>  FOREIGN KEY constraint failed 
>
>
> Below is the stack
> Error ticket for "formulator" Ticket ID 
>
> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>  FOREIGN KEY constraint failed Version 
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 703, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 151, in insert
> if form.accepts(request.vars, session):
>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
> 726, in insert
> ret = self._db._adapter.insert(self, self._listify(fields))
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 746, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
>
> Please help me, i dont know what to do, i have tried to look for solutions 
> online but i just dont understand them, may someone please give me light on 
> what i'm doing wrong.
>

-- 
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.


[web2py] Re: FOREIGN KEY constraint failed

2017-07-11 Thread Dave S


On Tuesday, July 11, 2017 at 2:39:46 PM UTC-7, Scheme Lab wrote:
>
> I think the filename ends with .sqlite doesnt it?
>

That's the actual database (if you're using sqlite3).  The dot-table files 
are part of pydal, with schema information used by the driver, etc, and are 
present for any database engine.

/dps
 

>
> On Wednesday, July 5, 2017 at 3:07:46 AM UTC-4, Dave S wrote:
>>
>>
>>
>> On Tuesday, July 4, 2017 at 11:34:11 PM UTC-7, mostwanted wrote:
>>>
>>> Hey Santi, how do i go about doing that, deleting all the tables in the 
>>> database backup folder?
>>>
>>
>> The easiest way is to use a command line, and delete the .table files. 
>>  In a linux system, and picking the application name from the ticket,
>>
>> cd [web2pydir]/applications/formulator/databases
>> rm *.table
>>
>> For Windows, the same except substitute del for rm.
>>
>> (the "backup" mentioned may be a nod to a hosting service, where you 
>> might not manipulate the file system directly..  For instance, for heroku, 
>> I think you'd actually do a git delete of any dot-table files, but I've 
>> only done node.js on heroku, so I'm just waving my hands.)
>>
>> /dps
>>
>>
>>
>>> On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:

 Go to the database folder backup and delete all the .tables. Perhaps a 
 change was not reflected on the creation of the table.

 A similar error ocurred to me and it was on the creation of the id's 
 references on the forange. But your code looks ok

 El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>
> this is the actual code Santi:
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table(govmntForm',
>
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>>
>> Hello,
>>
>> You should reference the table with the same name that is created so 
>> the table sould be like:
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference governmenttForm
>> '),migrate=False,fake_migrate=True)
>>
>> Best regards
>>
>>
>> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>>
>>> It is the actually code Tony, i just changed it after posting it. 
>>> The table name was initially *govmntForm* as it is referenced in 
>>> the *governmetFormPages* table.
>>>
>>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:

 Not sure if you're showing your actual code, but the table name is 
 spelled "governmenttForm" (note the extra "t"), and for the field 
 type, you 
 have "reference govmntForm".

 Anthony

 On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>
> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
> website where when i'm trying to record an entry i get an error:
>  FOREIGN KEY constraint failed
>
>
> I have been able to create 2 forms but other attempts to create 
> more forms fail!!
>
>
> These are my tables;
>
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  
> migrate=False,fake_migrate=True)
>
>
> db.define_table('governmenttForm',
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> 
> format='%(formName)s',migrate=False,fake_migrate=True)
>

[web2py] Re: FOREIGN KEY constraint failed

2017-07-11 Thread Scheme Lab
I think the filename ends with .sqlite doesnt it?

On Wednesday, July 5, 2017 at 3:07:46 AM UTC-4, Dave S wrote:
>
>
>
> On Tuesday, July 4, 2017 at 11:34:11 PM UTC-7, mostwanted wrote:
>>
>> Hey Santi, how do i go about doing that, deleting all the tables in the 
>> database backup folder?
>>
>
> The easiest way is to use a command line, and delete the .table files.  In 
> a linux system, and picking the application name from the ticket,
>
> cd [web2pydir]/applications/formulator/databases
> rm *.table
>
> For Windows, the same except substitute del for rm.
>
> (the "backup" mentioned may be a nod to a hosting service, where you might 
> not manipulate the file system directly..  For instance, for heroku, I 
> think you'd actually do a git delete of any dot-table files, but I've only 
> done node.js on heroku, so I'm just waving my hands.)
>
> /dps
>
>
>
>> On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:
>>>
>>> Go to the database folder backup and delete all the .tables. Perhaps a 
>>> change was not reflected on the creation of the table.
>>>
>>> A similar error ocurred to me and it was on the creation of the id's 
>>> references on the forange. But your code looks ok
>>>
>>> El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:

 this is the actual code Santi:

 db.define_table('government',
 Field('govName', requires=IS_NOT_EMPTY()),
 Field('tel', requires=IS_NOT_EMPTY()),
 Field('email', requires=IS_NOT_EMPTY()),
 format='%(govName)s',  migrate=False,fake_migrate=True)


 db.define_table(govmntForm',

 Field('formImage', 'upload'),
 Field('filledformImage', 'upload'),
 Field('formName',requires=IS_NOT_EMPTY()),
 Field('governmentName', 'reference government'), 
 format='%(formName)s',migrate=False,fake_migrate=True)

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()), 
 Field('formName', 'reference 
 govmntForm'),migrate=False,fake_migrate=True)


 On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>
> Hello,
>
> You should reference the table with the same name that is created so 
> the table sould be like:
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference governmenttForm
> '),migrate=False,fake_migrate=True)
>
> Best regards
>
>
> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>
>> It is the actually code Tony, i just changed it after posting it. The 
>> table name was initially *govmntForm* as it is referenced in the 
>> *governmetFormPages* table.
>>
>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>>
>>> Not sure if you're showing your actual code, but the table name is 
>>> spelled "governmenttForm" (note the extra "t"), and for the field type, 
>>> you 
>>> have "reference govmntForm".
>>>
>>> Anthony
>>>
>>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:

 Hi guys, i need help, i'm pulling my hairs out over here, i have a 
 website where when i'm trying to record an entry i get an error:
  FOREIGN KEY constraint failed


 I have been able to create 2 forms but other attempts to create 
 more forms fail!!


 These are my tables;


 db.define_table('government',
 Field('govName', requires=IS_NOT_EMPTY()),
 Field('tel', requires=IS_NOT_EMPTY()),
 Field('email', requires=IS_NOT_EMPTY()),
 format='%(govName)s',  
 migrate=False,fake_migrate=True)


 db.define_table('governmenttForm',
 Field('formImage', 'upload'),
 Field('filledformImage', 'upload'),
 Field('formName',requires=IS_NOT_EMPTY()),
 Field('governmentName', 'reference government'), 
 
 format='%(formName)s',migrate=False,fake_migrate=True)

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()), 
 Field('formName', 'reference 
 govmntForm'),migrate=False,fake_migrate=True)


 I am able to create a form for the governmentForm table but when i 
 try to load up 

Re: [web2py] Re: FOREIGN KEY constraint failed

2017-07-05 Thread Santiago Cartasegna
That would do the trick.

The backup means thtat before deleteng the files, you backup the folder!

2017-07-05 4:07 GMT-03:00 Dave S :

>
>
> On Tuesday, July 4, 2017 at 11:34:11 PM UTC-7, mostwanted wrote:
>>
>> Hey Santi, how do i go about doing that, deleting all the tables in the
>> database backup folder?
>>
>
> The easiest way is to use a command line, and delete the .table files.  In
> a linux system, and picking the application name from the ticket,
>
> cd [web2pydir]/applications/formulator/databases
> rm *.table
>
> For Windows, the same except substitute del for rm.
>
> (the "backup" mentioned may be a nod to a hosting service, where you might
> not manipulate the file system directly..  For instance, for heroku, I
> think you'd actually do a git delete of any dot-table files, but I've only
> done node.js on heroku, so I'm just waving my hands.)
>
> /dps
>
>
>
>> On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:
>>>
>>> Go to the database folder backup and delete all the .tables. Perhaps a
>>> change was not reflected on the creation of the table.
>>>
>>> A similar error ocurred to me and it was on the creation of the id's
>>> references on the forange. But your code looks ok
>>>
>>> El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:

 this is the actual code Santi:

 db.define_table('government',
 Field('govName', requires=IS_NOT_EMPTY()),
 Field('tel', requires=IS_NOT_EMPTY()),
 Field('email', requires=IS_NOT_EMPTY()),
 format='%(govName)s',  migrate=False,fake_migrate=True)


 db.define_table(govmntForm',

 Field('formImage', 'upload'),
 Field('filledformImage', 'upload'),
 Field('formName',requires=IS_NOT_EMPTY()),
 Field('governmentName', 'reference government'),
 format='%(formName)s',migrate=False,fake_migrate=True)

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()),
 Field('formName', 'reference
 govmntForm'),migrate=False,fake_migrate=True)


 On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>
> Hello,
>
> You should reference the table with the same name that is created so
> the table sould be like:
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()),
> Field('formName', 'reference governmenttForm
> '),migrate=False,fake_migrate=True)
>
> Best regards
>
>
> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>
>> It is the actually code Tony, i just changed it after posting it. The
>> table name was initially *govmntForm* as it is referenced in the
>> *governmetFormPages* table.
>>
>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>>
>>> Not sure if you're showing your actual code, but the table name is
>>> spelled "governmenttForm" (note the extra "t"), and for the field type, 
>>> you
>>> have "reference govmntForm".
>>>
>>> Anthony
>>>
>>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:

 Hi guys, i need help, i'm pulling my hairs out over here, i have a
 website where when i'm trying to record an entry i get an error:
  FOREIGN KEY constraint failed


 I have been able to create 2 forms but other attempts to create
 more forms fail!!


 These are my tables;


 db.define_table('government',
 Field('govName', requires=IS_NOT_EMPTY()),
 Field('tel', requires=IS_NOT_EMPTY()),
 Field('email', requires=IS_NOT_EMPTY()),
 format='%(govName)s',
 migrate=False,fake_migrate=True)


 db.define_table('governmenttForm',
 Field('formImage', 'upload'),
 Field('filledformImage', 'upload'),
 Field('formName',requires=IS_NOT_EMPTY()),
 Field('governmentName', 'reference government'),
 format='%(formName)s',migrate=
 False,fake_migrate=True)

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()),
 Field('formName', 'reference
 govmntForm'),migrate=False,fake_migrate=True)


 I am able to create a form for the governmentForm table but when i

[web2py] Re: FOREIGN KEY constraint failed

2017-07-05 Thread Dave S


On Tuesday, July 4, 2017 at 11:34:11 PM UTC-7, mostwanted wrote:
>
> Hey Santi, how do i go about doing that, deleting all the tables in the 
> database backup folder?
>

The easiest way is to use a command line, and delete the .table files.  In 
a linux system, and picking the application name from the ticket,

cd [web2pydir]/applications/formulator/databases
rm *.table

For Windows, the same except substitute del for rm.

(the "backup" mentioned may be a nod to a hosting service, where you might 
not manipulate the file system directly..  For instance, for heroku, I 
think you'd actually do a git delete of any dot-table files, but I've only 
done node.js on heroku, so I'm just waving my hands.)

/dps



> On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:
>>
>> Go to the database folder backup and delete all the .tables. Perhaps a 
>> change was not reflected on the creation of the table.
>>
>> A similar error ocurred to me and it was on the creation of the id's 
>> references on the forange. But your code looks ok
>>
>> El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>>>
>>> this is the actual code Santi:
>>>
>>> db.define_table('government',
>>> Field('govName', requires=IS_NOT_EMPTY()),
>>> Field('tel', requires=IS_NOT_EMPTY()),
>>> Field('email', requires=IS_NOT_EMPTY()),
>>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>>
>>>
>>> db.define_table(govmntForm',
>>>
>>> Field('formImage', 'upload'),
>>> Field('filledformImage', 'upload'),
>>> Field('formName',requires=IS_NOT_EMPTY()),
>>> Field('governmentName', 'reference government'), 
>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>
>>> db.define_table('governmetFormPages',
>>> Field('formImage', 'upload'),
>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>> Field('formName', 'reference 
>>> govmntForm'),migrate=False,fake_migrate=True)
>>>
>>>
>>> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:

 Hello,

 You should reference the table with the same name that is created so 
 the table sould be like:

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()), 
 Field('formName', 'reference governmenttForm
 '),migrate=False,fake_migrate=True)

 Best regards


 El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>
> It is the actually code Tony, i just changed it after posting it. The 
> table name was initially *govmntForm* as it is referenced in the 
> *governmetFormPages* table.
>
> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>
>> Not sure if you're showing your actual code, but the table name is 
>> spelled "governmenttForm" (note the extra "t"), and for the field type, 
>> you 
>> have "reference govmntForm".
>>
>> Anthony
>>
>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>
>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>>> website where when i'm trying to record an entry i get an error:
>>>  FOREIGN KEY constraint failed
>>>
>>>
>>> I have been able to create 2 forms but other attempts to create more 
>>> forms fail!!
>>>
>>>
>>> These are my tables;
>>>
>>>
>>> db.define_table('government',
>>> Field('govName', requires=IS_NOT_EMPTY()),
>>> Field('tel', requires=IS_NOT_EMPTY()),
>>> Field('email', requires=IS_NOT_EMPTY()),
>>> format='%(govName)s',  
>>> migrate=False,fake_migrate=True)
>>>
>>>
>>> db.define_table('governmenttForm',
>>> Field('formImage', 'upload'),
>>> Field('filledformImage', 'upload'),
>>> Field('formName',requires=IS_NOT_EMPTY()),
>>> Field('governmentName', 'reference government'), 
>>> 
>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>
>>> db.define_table('governmetFormPages',
>>> Field('formImage', 'upload'),
>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>> Field('formName', 'reference 
>>> govmntForm'),migrate=False,fake_migrate=True)
>>>
>>>
>>> I am able to create a form for the governmentForm table but when i 
>>> try to load up the pages for governmentFormPages table i get the error
>>>  FOREIGN KEY constraint failed 
>>>
>>>
>>> Below is the stack
>>> Error ticket for "formulator" Ticket ID 
>>>
>>> 

[web2py] Re: FOREIGN KEY constraint failed

2017-07-05 Thread mostwanted
Hey Santi, how do i go about doing that, deleting all the tables in the 
database backup folder?

On Tuesday, July 4, 2017 at 12:08:44 AM UTC+2, Santiago Cartasegna wrote:
>
> Go to the database folder backup and delete all the .tables. Perhaps a 
> change was not reflected on the creation of the table.
>
> A similar error ocurred to me and it was on the creation of the id's 
> references on the forange. But your code looks ok
>
> El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>>
>> this is the actual code Santi:
>>
>> db.define_table('government',
>> Field('govName', requires=IS_NOT_EMPTY()),
>> Field('tel', requires=IS_NOT_EMPTY()),
>> Field('email', requires=IS_NOT_EMPTY()),
>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>
>>
>> db.define_table(govmntForm',
>>
>> Field('formImage', 'upload'),
>> Field('filledformImage', 'upload'),
>> Field('formName',requires=IS_NOT_EMPTY()),
>> Field('governmentName', 'reference government'), 
>> format='%(formName)s',migrate=False,fake_migrate=True)
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference 
>> govmntForm'),migrate=False,fake_migrate=True)
>>
>>
>> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>>>
>>> Hello,
>>>
>>> You should reference the table with the same name that is created so the 
>>> table sould be like:
>>>
>>> db.define_table('governmetFormPages',
>>> Field('formImage', 'upload'),
>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>> Field('formName', 'reference governmenttForm
>>> '),migrate=False,fake_migrate=True)
>>>
>>> Best regards
>>>
>>>
>>> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:

 It is the actually code Tony, i just changed it after posting it. The 
 table name was initially *govmntForm* as it is referenced in the 
 *governmetFormPages* table.

 On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>
> Not sure if you're showing your actual code, but the table name is 
> spelled "governmenttForm" (note the extra "t"), and for the field type, 
> you 
> have "reference govmntForm".
>
> Anthony
>
> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>
>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>> website where when i'm trying to record an entry i get an error:
>>  FOREIGN KEY constraint failed
>>
>>
>> I have been able to create 2 forms but other attempts to create more 
>> forms fail!!
>>
>>
>> These are my tables;
>>
>>
>> db.define_table('government',
>> Field('govName', requires=IS_NOT_EMPTY()),
>> Field('tel', requires=IS_NOT_EMPTY()),
>> Field('email', requires=IS_NOT_EMPTY()),
>> format='%(govName)s',  
>> migrate=False,fake_migrate=True)
>>
>>
>> db.define_table('governmenttForm',
>> Field('formImage', 'upload'),
>> Field('filledformImage', 'upload'),
>> Field('formName',requires=IS_NOT_EMPTY()),
>> Field('governmentName', 'reference government'), 
>> format='%(formName)s',migrate=False,fake_migrate=True)
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference 
>> govmntForm'),migrate=False,fake_migrate=True)
>>
>>
>> I am able to create a form for the governmentForm table but when i 
>> try to load up the pages for governmentFormPages table i get the error
>>  FOREIGN KEY constraint failed 
>>
>>
>> Below is the stack
>> Error ticket for "formulator" Ticket ID 
>>
>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>  FOREIGN KEY constraint failed 
>> Version 
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py"
>>  
>> ,
>>  line 703, in 
>>   File 

[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread Santiago Cartasegna
Go to the database folder backup and delete all the .tables. Perhaps a 
change was not reflected on the creation of the table.

A similar error ocurred to me and it was on the creation of the id's 
references on the forange. But your code looks ok

El lunes, 3 de julio de 2017, 15:50:45 (UTC-3), mostwanted escribió:
>
> this is the actual code Santi:
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table(govmntForm',
>
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>>
>> Hello,
>>
>> You should reference the table with the same name that is created so the 
>> table sould be like:
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference governmenttForm
>> '),migrate=False,fake_migrate=True)
>>
>> Best regards
>>
>>
>> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>>
>>> It is the actually code Tony, i just changed it after posting it. The 
>>> table name was initially *govmntForm* as it is referenced in the 
>>> *governmetFormPages* table.
>>>
>>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:

 Not sure if you're showing your actual code, but the table name is 
 spelled "governmenttForm" (note the extra "t"), and for the field type, 
 you 
 have "reference govmntForm".

 Anthony

 On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>
> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
> website where when i'm trying to record an entry i get an error:
>  FOREIGN KEY constraint failed
>
>
> I have been able to create 2 forms but other attempts to create more 
> forms fail!!
>
>
> These are my tables;
>
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table('governmenttForm',
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> I am able to create a form for the governmentForm table but when i try 
> to load up the pages for governmentFormPages table i get the error
>  FOREIGN KEY constraint failed 
>
>
> Below is the stack
> Error ticket for "formulator" Ticket ID 
>
> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>  FOREIGN KEY constraint failed Version 
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 703, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 151, in insert
> if form.accepts(request.vars, 

[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread mostwanted
this is the actual code Santi:

db.define_table('government',
Field('govName', requires=IS_NOT_EMPTY()),
Field('tel', requires=IS_NOT_EMPTY()),
Field('email', requires=IS_NOT_EMPTY()),
format='%(govName)s',  migrate=False,fake_migrate=True)


db.define_table(govmntForm',

Field('formImage', 'upload'),
Field('filledformImage', 'upload'),
Field('formName',requires=IS_NOT_EMPTY()),
Field('governmentName', 'reference government'), 
format='%(formName)s',migrate=False,fake_migrate=True)

db.define_table('governmetFormPages',
Field('formImage', 'upload'),
Field('formTitle',requires=IS_NOT_EMPTY()), 
Field('formName', 'reference 
govmntForm'),migrate=False,fake_migrate=True)


On Monday, July 3, 2017 at 4:51:47 PM UTC+2, Santiago Cartasegna wrote:
>
> Hello,
>
> You should reference the table with the same name that is created so the 
> table sould be like:
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference governmenttForm
> '),migrate=False,fake_migrate=True)
>
> Best regards
>
>
> El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>>
>> It is the actually code Tony, i just changed it after posting it. The 
>> table name was initially *govmntForm* as it is referenced in the 
>> *governmetFormPages* table.
>>
>> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>>
>>> Not sure if you're showing your actual code, but the table name is 
>>> spelled "governmenttForm" (note the extra "t"), and for the field type, you 
>>> have "reference govmntForm".
>>>
>>> Anthony
>>>
>>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:

 Hi guys, i need help, i'm pulling my hairs out over here, i have a 
 website where when i'm trying to record an entry i get an error:
  FOREIGN KEY constraint failed


 I have been able to create 2 forms but other attempts to create more 
 forms fail!!


 These are my tables;


 db.define_table('government',
 Field('govName', requires=IS_NOT_EMPTY()),
 Field('tel', requires=IS_NOT_EMPTY()),
 Field('email', requires=IS_NOT_EMPTY()),
 format='%(govName)s',  migrate=False,fake_migrate=True)


 db.define_table('governmenttForm',
 Field('formImage', 'upload'),
 Field('filledformImage', 'upload'),
 Field('formName',requires=IS_NOT_EMPTY()),
 Field('governmentName', 'reference government'), 
 format='%(formName)s',migrate=False,fake_migrate=True)

 db.define_table('governmetFormPages',
 Field('formImage', 'upload'),
 Field('formTitle',requires=IS_NOT_EMPTY()), 
 Field('formName', 'reference 
 govmntForm'),migrate=False,fake_migrate=True)


 I am able to create a form for the governmentForm table but when i try 
 to load up the pages for governmentFormPages table i get the error
  FOREIGN KEY constraint failed 


 Below is the stack
 Error ticket for "formulator" Ticket ID 

 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
  FOREIGN KEY constraint failed Version 
 web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 

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

 Traceback (most recent call last):
   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
 restricted
 exec ccode in environment
   File 
 "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
 ,
  line 703, in 
   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
 self._caller = lambda f: f()
   File 
 "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
 ,
  line 151, in insert
 if form.accepts(request.vars, session):
   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
 self.vars.id = self.table.insert(**fields)
   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
 726, in insert
 ret = self._db._adapter.insert(self, self._listify(fields))
   File 
 "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", line 
 746, in insert
 raise e
 IntegrityError: FOREIGN KEY 

[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread Santiago Cartasegna
Hello,

You should reference the table with the same name that is created so the 
table sould be like:

db.define_table('governmetFormPages',
Field('formImage', 'upload'),
Field('formTitle',requires=IS_NOT_EMPTY()), 
Field('formName', 'reference governmenttForm
'),migrate=False,fake_migrate=True)

Best regards


El lunes, 3 de julio de 2017, 4:15:18 (UTC-3), mostwanted escribió:
>
> It is the actually code Tony, i just changed it after posting it. The 
> table name was initially *govmntForm* as it is referenced in the 
> *governmetFormPages* table.
>
> On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>>
>> Not sure if you're showing your actual code, but the table name is 
>> spelled "governmenttForm" (note the extra "t"), and for the field type, you 
>> have "reference govmntForm".
>>
>> Anthony
>>
>> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>>
>>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>>> website where when i'm trying to record an entry i get an error:
>>>  FOREIGN KEY constraint failed
>>>
>>>
>>> I have been able to create 2 forms but other attempts to create more 
>>> forms fail!!
>>>
>>>
>>> These are my tables;
>>>
>>>
>>> db.define_table('government',
>>> Field('govName', requires=IS_NOT_EMPTY()),
>>> Field('tel', requires=IS_NOT_EMPTY()),
>>> Field('email', requires=IS_NOT_EMPTY()),
>>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>>
>>>
>>> db.define_table('governmenttForm',
>>> Field('formImage', 'upload'),
>>> Field('filledformImage', 'upload'),
>>> Field('formName',requires=IS_NOT_EMPTY()),
>>> Field('governmentName', 'reference government'), 
>>> format='%(formName)s',migrate=False,fake_migrate=True)
>>>
>>> db.define_table('governmetFormPages',
>>> Field('formImage', 'upload'),
>>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>>> Field('formName', 'reference 
>>> govmntForm'),migrate=False,fake_migrate=True)
>>>
>>>
>>> I am able to create a form for the governmentForm table but when i try 
>>> to load up the pages for governmentFormPages table i get the error
>>>  FOREIGN KEY constraint failed 
>>>
>>>
>>> Below is the stack
>>> Error ticket for "formulator" Ticket ID 
>>>
>>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>>  FOREIGN KEY constraint failed Version 
>>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>>>
>>> 1.
>>> 2.
>>> 3.
>>> 4.
>>> 5.
>>> 6.
>>> 7.
>>> 8.
>>> 9.
>>> 10.
>>> 11.
>>> 12.
>>> 13.
>>> 14.
>>> 15.
>>> 16.
>>>
>>> Traceback (most recent call last):
>>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in 
>>> restricted
>>> exec ccode in environment
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> ,
>>>  line 703, in 
>>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
>>> self._caller = lambda f: f()
>>>   File 
>>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>>> ,
>>>  line 151, in insert
>>> if form.accepts(request.vars, session):
>>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>>> self.vars.id = self.table.insert(**fields)
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>>> 726, in insert
>>> ret = self._db._adapter.insert(self, self._listify(fields))
>>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>>> line 746, in insert
>>> raise e
>>> IntegrityError: FOREIGN KEY constraint failed
>>>
>>>
>>> Please help me, i dont know what to do, i have tried to look for 
>>> solutions online but i just dont understand them, may someone please give 
>>> me light on what i'm doing wrong.
>>>
>>

-- 
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.


[web2py] Re: FOREIGN KEY constraint failed

2017-07-03 Thread mostwanted
It is the actually code Tony, i just changed it after posting it. The table 
name was initially *govmntForm* as it is referenced in the 
*governmetFormPages* table.

On Sunday, July 2, 2017 at 7:48:43 PM UTC+2, Anthony wrote:
>
> Not sure if you're showing your actual code, but the table name is spelled 
> "governmenttForm" (note the extra "t"), and for the field type, you have 
> "reference govmntForm".
>
> Anthony
>
> On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>>
>> Hi guys, i need help, i'm pulling my hairs out over here, i have a 
>> website where when i'm trying to record an entry i get an error:
>>  FOREIGN KEY constraint failed
>>
>>
>> I have been able to create 2 forms but other attempts to create more 
>> forms fail!!
>>
>>
>> These are my tables;
>>
>>
>> db.define_table('government',
>> Field('govName', requires=IS_NOT_EMPTY()),
>> Field('tel', requires=IS_NOT_EMPTY()),
>> Field('email', requires=IS_NOT_EMPTY()),
>> format='%(govName)s',  migrate=False,fake_migrate=True)
>>
>>
>> db.define_table('governmenttForm',
>> Field('formImage', 'upload'),
>> Field('filledformImage', 'upload'),
>> Field('formName',requires=IS_NOT_EMPTY()),
>> Field('governmentName', 'reference government'), 
>> format='%(formName)s',migrate=False,fake_migrate=True)
>>
>> db.define_table('governmetFormPages',
>> Field('formImage', 'upload'),
>> Field('formTitle',requires=IS_NOT_EMPTY()), 
>> Field('formName', 'reference 
>> govmntForm'),migrate=False,fake_migrate=True)
>>
>>
>> I am able to create a form for the governmentForm table but when i try to 
>> load up the pages for governmentFormPages table i get the error
>>  FOREIGN KEY constraint failed 
>>
>>
>> Below is the stack
>> Error ticket for "formulator" Ticket ID 
>>
>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>>  FOREIGN KEY constraint failed Version 
>> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>>
>> Traceback (most recent call last):
>>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in restricted
>> exec ccode in environment
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> ,
>>  line 703, in 
>>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
>> self._caller = lambda f: f()
>>   File 
>> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
>> ,
>>  line 151, in insert
>> if form.accepts(request.vars, session):
>>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
>> self.vars.id = self.table.insert(**fields)
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
>> 726, in insert
>> ret = self._db._adapter.insert(self, self._listify(fields))
>>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
>> line 746, in insert
>> raise e
>> IntegrityError: FOREIGN KEY constraint failed
>>
>>
>> Please help me, i dont know what to do, i have tried to look for 
>> solutions online but i just dont understand them, may someone please give 
>> me light on what i'm doing wrong.
>>
>

-- 
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.


[web2py] Re: FOREIGN KEY constraint failed

2017-07-02 Thread Anthony
Not sure if you're showing your actual code, but the table name is spelled 
"governmenttForm" (note the extra "t"), and for the field type, you have 
"reference govmntForm".

Anthony

On Sunday, July 2, 2017 at 4:37:22 AM UTC-4, mostwanted wrote:
>
> Hi guys, i need help, i'm pulling my hairs out over here, i have a website 
> where when i'm trying to record an entry i get an error:
>  FOREIGN KEY constraint failed
>
>
> I have been able to create 2 forms but other attempts to create more forms 
> fail!!
>
>
> These are my tables;
>
>
> db.define_table('government',
> Field('govName', requires=IS_NOT_EMPTY()),
> Field('tel', requires=IS_NOT_EMPTY()),
> Field('email', requires=IS_NOT_EMPTY()),
> format='%(govName)s',  migrate=False,fake_migrate=True)
>
>
> db.define_table('governmenttForm',
> Field('formImage', 'upload'),
> Field('filledformImage', 'upload'),
> Field('formName',requires=IS_NOT_EMPTY()),
> Field('governmentName', 'reference government'), 
> format='%(formName)s',migrate=False,fake_migrate=True)
>
> db.define_table('governmetFormPages',
> Field('formImage', 'upload'),
> Field('formTitle',requires=IS_NOT_EMPTY()), 
> Field('formName', 'reference 
> govmntForm'),migrate=False,fake_migrate=True)
>
>
> I am able to create a form for the governmentForm table but when i try to 
> load up the pages for governmentFormPages table i get the error
>  FOREIGN KEY constraint failed 
>
>
> Below is the stack
> Error ticket for "formulator" Ticket ID 
>
> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ace4-3692239493c4
>  FOREIGN KEY constraint failed Version 
> web2py™ Version 2.14.6-stable+timestamp.2016.05.10.00.21.47 Traceback 
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
>
> Traceback (most recent call last):
>   File "/home/mostwanted/web2py/gluon/restricted.py", line 227, in restricted
> exec ccode in environment
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 703, in 
>   File "/home/mostwanted/web2py/gluon/globals.py", line 417, in 
> self._caller = lambda f: f()
>   File 
> "/home/mostwanted/web2py/applications/formulator/controllers/appadmin.py" 
> ,
>  line 151, in insert
> if form.accepts(request.vars, session):
>   File "/home/mostwanted/web2py/gluon/sqlhtml.py", line 1746, in accepts
> self.vars.id = self.table.insert(**fields)
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/objects.py", line 
> 726, in insert
> ret = self._db._adapter.insert(self, self._listify(fields))
>   File "/home/mostwanted/web2py/gluon/packages/dal/pydal/adapters/base.py", 
> line 746, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
>
> Please help me, i dont know what to do, i have tried to look for solutions 
> online but i just dont understand them, may someone please give me light on 
> what i'm doing wrong.
>

-- 
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.


[web2py] Re: Foreign key constraint failed

2017-01-11 Thread pilzsuppe
Hello Anthony, my eintrag_erstellen is a html view:

--

{{extend 'layout.html'}}

{{block header}}
 
{{end}}


Erstelle einen neuen Beitrag über das Thema {{=category.name.title()}}



{{=form}}

--

I gain access this way: 
1. I click this button in another view:

--

Neuer Eintrag

--

which leads me to this:

--

def erstellen():
rows = db(db.category).select()
form = SQLFORM(db.eintrag).process(next='eintrag_betrachten/[id]')
return locals()

--

and this view:

--

{{extend 'layout.html'}}

{{block header}}
 
{{end}}


Profil | Ausloggen | Mitgliedschaft beenden



Eintrag erstellen


{{for category in rows:}}


{{=A(category.name.title(),_class='btn',_href=URL('eintrag_erstellen',args=category.name))}}

{{pass}}

--

There all my categories got listed in a single button. When I click on one 
of them, I gain acces to my eintrag_erstellen view

-- 
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.


[web2py] Re: Foreign key constraint failed

2017-01-10 Thread Anthony
How are you generating the URL to access eintrag_erstellen, and are you 
sure the integer you are using in the URL is in fact the record ID of one 
of the records in db.category?

Anthony

On Tuesday, January 10, 2017 at 6:07:17 PM UTC-5, pilzsu...@emailn.de wrote:
>
> Good day,
>
> I was following the video tutorial of Massimo, just as other users here. 
> But when I want to submit a post I get the error
> >IntegrityError: foreign key constraint failed<
>
> ---My db.py:---
>
> db.define_table('category', 
> Field('name',requires=IS_IN_SET(['suess','sauer','frostig','fruchtig','schokoladig','einfach_lecker'])))
>
> db.define_table('eintrag',
> Field('category','reference category',writable=False),
> Field('eintragId', 
> 'integer',readable=False,writable=False),
> Field('standort','string',requires=IS_NOT_EMPTY()),
> Field('laden','string'),
> Field('eis', 
> requires=IS_IN_SET(['Schokolade','Vanille','Erdbeere','Pistazie','Banane','Andere',])),
> Field('eigenschaft','text'),
> auth.signature)
>
> ---My default.py:---
>
> def get_category():
> category_name = request.args(0)
> category = db.category(name=category_name)
> if not category:
> session.flash = 'Element nicht gefunden'
> redirect(URL('eis'))
> return category
>
> def eintrag_erstellen():
> category = get_category()
> db.eintrag.category.default = category.id
> form = SQLFORM(db.eintrag).process(next='eintrag_betrachten/[id]')
> return locals()
>
> ---My view:---
>
> {{extend 'layout.html'}}
>
> {{block header}}
>  
> {{end}}
>
> 
> Erstelle einen neuen Beitrag über das Thema {{=category.name.title()}}
> 
>
> 
>
> {{=form}}
>
>
>
> -
> this is exactly the same code as massimo used (just with german words 
> instead of english ones, but this does not cause the problem). I already 
> found threads about this problem and their solution was to create tabled 
> with appadmin. I did. But the same error. 
> If I delete the row in default.py >db.eintrag.category.default = 
> category.id< everything works just fine but the fact that the category 
> field is "None". 
>

-- 
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.


[web2py] Re: FOREIGN KEY constraint failed error when "Click to delete" user account

2016-01-26 Thread Yi Liu
I read more about "Foreign Key constraint" in sqlite docs (Should have done 
this in the begining).

The error cause is there is a reference key to the auth.user in another 
table. So sqlite cannot delete the user without "ON DELETE CASCADE".

Is there any place I can config "on delete cascade" or I just find a new 
bug? :)

Best, Yi 


On Monday, January 25, 2016 at 8:59:17 AM UTC-8, Massimo Di Pierro wrote:
>
> Do you still get the ticket if you remove the logic for the additional 
> form on the profile page?
>
> On Sunday, 24 January 2016 21:11:33 UTC-6, Yi Liu wrote:
>>
>> Dear fellow w2p users,
>>
>> First, thank you so much for providing this great app Web2Py for *free*.
>>
>> Recently I updated my app to allow user to delete account themselves.
>>
>> auth.settings.allow_delete_accounts= True
>>
>>
>> Today, I received feedback from user that that function is broken on my 
>> site.
>>
>> Then I realize there is a ticket when that function is called.
>>
>>  FOREIGN KEY constraint failed
>> Version
>> web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39
>> Python Python 2.7.11: 
>> /home/liuyidh/.pyenv/versions/miniconda-3.16.0/bin/python (prefix: 
>> /home/liuyidh/.pyenv/versions/miniconda-3.16.0)
>> Traceback
>>
>> 1.
>> 2.
>> 3.
>> 4.
>> 5.
>> 6.
>> 7.
>> 8.
>> 9.
>> 10.
>> 11.
>> 12.
>> 13.
>> 14.
>> 15.
>> 16.
>> 17.
>> 18.
>> 19.
>> 20.
>>
>> Traceback (most recent call last):
>>   File "/home/liuyidh/lovelovebean.com/gluon/restricted.py", line 227, in 
>> restricted
>> exec ccode in environment
>>   File 
>> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" 
>> , line 97, 
>> in 
>>   File "/home/liuyidh/lovelovebean.com/gluon/globals.py", line 412, in 
>> 
>> self._caller = lambda f: f()
>>   File 
>> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" 
>> , line 55, 
>> in user
>> return dict(form=auth(), formFil=formFil)
>>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 1923, in 
>> __call__
>> return getattr(self, args[0])()
>>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 4025, in profile
>> self.log_event(log, self.user)
>>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 2521, in 
>> log_event
>> origin=origin, user_id=user_id)
>>   File "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/objects.py", 
>> line 731, in insert
>> ret = self._db._adapter.insert(self, self._listify(fields))
>>   File 
>> "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/adapters/base.py", 
>> line 746, in insert
>> raise e
>> IntegrityError: FOREIGN KEY constraint failed
>>
>>
>>
>> I searched stackoverflow for tips. It seems the causes are different. 
>> Some are due to migration, some due to wrong reference, others due to 
>> auth().
>>
>> I have a user form in the profile page:
>>
>> def user():
>> if request.args(0)=='profile':
>> db.auth_criteria.user_id.default = auth.user_id
>> record = db.auth_criteria(db.auth_criteria.user_id==auth.user_id)
>> formFil=SQLFORM(db.auth_criteria, 
>> record=record,
>> labels = {'salePrice':XML('TWO-A-DAY Clothing & Home 
>> Goods (By Sale Price)'), 
>>   'tgPrice':XML('ONE-A-DAY Travel and Gear  
>> (By Sale Price)'),
>>   'aveRev':XML('By Avereage Ratings'),
>>   'percSave':XML('By Percentage Saved'),
>>   'genderPref':XML('By Gender of Products 
>> AND-gate. Other filters apply')
>>   },
>> buttons = [TAG.button('Set Mine', _class='btn-primary')])
>> if formFil.process().accepted:
>> response.flash = XML('Your preference is recorded. Get 
>> ready for lovely beans.')
>> return dict(form=auth(), formFil=formFil)
>> else:
>> return dict(form=auth())
>>
>> I have a custom defined table:
>>
>> db.define_table('auth_criteria',
>>Field ('user_id', 
>> 'reference auth_user', readable=False, writable=False),
>>Field ('salePrice', 
>> 'integer', widget=SQLFORM 
>> .widgets.radio.widget, 
>> requires = IS_IN_SET 
>> (salePrice)),
>>Field ('tgPrice', 
>> 'integer', widget=SQLFORM 
>> .widgets.radio.widget, 
>> requires = IS_IN_SET 
>> (tgPrice)),
>>Field ('aveRev', 
>> 'integer', requires = IS_IN_SET 
>> (aveRev)),
>>Field 

[web2py] Re: FOREIGN KEY constraint failed error when "Click to delete" user account

2016-01-25 Thread Massimo Di Pierro
Do you still get the ticket if you remove the logic for the additional form 
on the profile page?

On Sunday, 24 January 2016 21:11:33 UTC-6, Yi Liu wrote:
>
> Dear fellow w2p users,
>
> First, thank you so much for providing this great app Web2Py for *free*.
>
> Recently I updated my app to allow user to delete account themselves.
>
> auth.settings.allow_delete_accounts= True
>
>
> Today, I received feedback from user that that function is broken on my 
> site.
>
> Then I realize there is a ticket when that function is called.
>
>  FOREIGN KEY constraint failed
> Version
> web2py™ Version 2.13.4-stable+timestamp.2015.12.26.04.59.39
> Python Python 2.7.11: 
> /home/liuyidh/.pyenv/versions/miniconda-3.16.0/bin/python (prefix: 
> /home/liuyidh/.pyenv/versions/miniconda-3.16.0)
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
> 8.
> 9.
> 10.
> 11.
> 12.
> 13.
> 14.
> 15.
> 16.
> 17.
> 18.
> 19.
> 20.
>
> Traceback (most recent call last):
>   File "/home/liuyidh/lovelovebean.com/gluon/restricted.py", line 227, in 
> restricted
> exec ccode in environment
>   File 
> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" 
> , line 97, in 
> 
>   File "/home/liuyidh/lovelovebean.com/gluon/globals.py", line 412, in 
> 
> self._caller = lambda f: f()
>   File 
> "/home/liuyidh/lovelovebean.com/applications/LLBean/controllers/default.py" 
> , line 55, in 
> user
> return dict(form=auth(), formFil=formFil)
>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 1923, in __call__
> return getattr(self, args[0])()
>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 4025, in profile
> self.log_event(log, self.user)
>   File "/home/liuyidh/lovelovebean.com/gluon/tools.py", line 2521, in 
> log_event
> origin=origin, user_id=user_id)
>   File "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/objects.py", 
> line 731, in insert
> ret = self._db._adapter.insert(self, self._listify(fields))
>   File 
> "/home/liuyidh/lovelovebean.com/gluon/packages/dal/pydal/adapters/base.py", 
> line 746, in insert
> raise e
> IntegrityError: FOREIGN KEY constraint failed
>
>
>
> I searched stackoverflow for tips. It seems the causes are different. Some 
> are due to migration, some due to wrong reference, others due to auth().
>
> I have a user form in the profile page:
>
> def user():
> if request.args(0)=='profile':
> db.auth_criteria.user_id.default = auth.user_id
> record = db.auth_criteria(db.auth_criteria.user_id==auth.user_id)
> formFil=SQLFORM(db.auth_criteria, 
> record=record,
> labels = {'salePrice':XML('TWO-A-DAY Clothing & Home 
> Goods (By Sale Price)'), 
>   'tgPrice':XML('ONE-A-DAY Travel and Gear  
> (By Sale Price)'),
>   'aveRev':XML('By Avereage Ratings'),
>   'percSave':XML('By Percentage Saved'),
>   'genderPref':XML('By Gender of Products 
> AND-gate. Other filters apply')
>   },
> buttons = [TAG.button('Set Mine', _class='btn-primary')])
> if formFil.process().accepted:
> response.flash = XML('Your preference is recorded. Get 
> ready for lovely beans.')
> return dict(form=auth(), formFil=formFil)
> else:
> return dict(form=auth())
>
> I have a custom defined table:
>
> db.define_table('auth_criteria',
>Field ('user_id', 
> 'reference auth_user', readable=False, writable=False),
>Field ('salePrice', 
> 'integer', widget=SQLFORM 
> .widgets.radio.widget, 
> requires = IS_IN_SET 
> (salePrice)),
>Field ('tgPrice', 
> 'integer', widget=SQLFORM 
> .widgets.radio.widget, 
> requires = IS_IN_SET 
> (tgPrice)),
>Field ('aveRev', 
> 'integer', requires = IS_IN_SET 
> (aveRev)),
>Field ('percSave', 
> 'integer', requires = IS_IN_SET 
> (percSave)),
>
> ...

-- 
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] Re: FOREIGN KEY constraint failed error when "Click to delete" user account

2016-01-25 Thread Yi Liu
Thank you for your suggestion, Massimo.

I deleted the logic. The only thing under def user() is now:

return dict(form=auth())


I also modified the logic in user.html by ''' '''.


{{
'''
if request.args(0)=='profile':
=H2('Your Filters:')
=XML('Note: Filters are logically OR-gates (except for gender AND-gate). 
You will get an email when ANY of the "price", "ratings", or "percentage 
savings" criteria is matched. If you only want to use ratings filter, y
ou can set sale price to "Nope."')
=formFil
pass
'''
}}


Still get the same error.

Here is the sqlite argument list in the ticket, if it helps:

Function argument list  

(self=, 
table=, 
fields=[(, 'auth'), 
(, datetime.datetime(2016, 1, 25, 9, 
16, 33, 848792)), (, '164.67.9.184'), 
(, 207L), (, 'User 207 Profile updated')])





Thanks again.


On Monday, January 25, 2016 at 8:59:17 AM UTC-8, Massimo Di Pierro wrote:
>
> Do you still get the ticket if you remove the logic for the additional 
> form on the profile page?
>
>

-- 
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.


[web2py] Re: foreign key constraint failed

2015-03-20 Thread Leonel Câmara
I'm guessing there's no user with the id 6

-- 
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.


Re: [web2py] Re: foreign key constraint failed

2015-03-20 Thread António Ramos
yep.
you are right.
I was using amostra.n but should be amostra.id

Thank u for your time as usual Leonel.

Regards

2015-03-20 16:50 GMT+00:00 Leonel Câmara leonelcam...@gmail.com:

 In that case amostra.n is not pointing to a valid amostra.

 --
 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.


-- 
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.


Re: [web2py] Re: foreign key constraint failed

2015-03-20 Thread António Ramos
Nop,
i´m user number 6.


2015-03-20 13:06 GMT+00:00 Leonel Câmara leonelcam...@gmail.com:

 I'm guessing there's no user with the id 6

 --
 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.


-- 
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.


[web2py] Re: foreign key constraint failed

2015-03-20 Thread Leonel Câmara
In that case amostra.n is not pointing to a valid amostra.

-- 
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.


[web2py] Re: foreign key constraint failed ???

2013-12-09 Thread Niphlod
foreign_keys = True keeps your data safe. Ignoring it means that your data 
doesn't respect referential integrity (meaning, it's faulty). Every major 
db engine forces it by default, SQLite instead needs an explicit 
declaration to enable it.
You'd really need to check if all of your data is consistent ^_^ 

On Sunday, December 8, 2013 6:20:50 PM UTC+1, Alan Etkin wrote:

 If possible I prefer to keep foreign_keys=True for db integrity.


 Another similar thread 

 https://groups.google.com/d/msg/web2py/klspqXpha4E/mCwQ6HC5IhAJ


-- 
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: foreign key constraint failed ???

2013-12-08 Thread Ivo
though it may not be the preferred solution I resolved it by adding:
adapter_args=dict(foreign_keys=False) to db = 
DAL('sqlite://storage.sqlite') in db.py


On Sunday, December 8, 2013 3:16:36 PM UTC+1, Ivan Gazzola wrote:

 I can't resolve this ticket in my app. I try to insert in 
 Pazienti_Consulenza from appadmin but i've always this error:
 
 class 'sqlite3.IntegrityError' foreign key constraint failed
 

 This is my model:

 db.define_table('Nominativi',
 Field('nome',notnull=True, represent=lambda nome:nome.title()),
 Field('categoria',db.Categorie_Nominativi,default='1'),
 Field('sesso',requires=IS_EMPTY_OR(IS_IN_SET(['maschio','femmina']))),
 Field('mail',requires=IS_EMPTY_OR(IS_EMAIL(error_message=T('Inserire 
 Una Mail Valida',
 Field('indirizzo'),
 Field('localita', label='Località'),
 Field('cap',requires=IS_EMPTY_OR(IS_LENGTH(5,5, 
 error_message=T('Inserire Un CAP valido',
 Field('provincia',requires=IS_EMPTY_OR(IS_IN_SET(Elenco_Province, 
 zero=T('Selezionare una Provincia',
 Field('codice_fiscale',length=20),
 Field('partita_iva',length=20),
 Field('data_di_nascita','date'),
 Field('professione'),
 Field('padre'),
 Field('madre'),
 Field('inviato_da'),
 Field('id_precendente','integer'),
 format=lambda 
 r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])

 db.Nominativi.nome.filter_in = lambda value : w2p_encrypt(value,key=chiave)
 db.Nominativi.nome.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.mail.filter_in = lambda value : w2p_encrypt(value,key=chiave)
 db.Nominativi.mail.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.indirizzo.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.indirizzo.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.localita.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.localita.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.cap.filter_in = lambda value : w2p_encrypt(value,key=chiave)
 db.Nominativi.cap.filter_out = lambda value : w2p_decrypt(value,key=chiave)
 db.Nominativi.codice_fiscale.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.codice_fiscale.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.padre.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.padre.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.madre.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.madre.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)

 db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
 db.Nominativi.categoria.represent = lambda id,row: row.categoria
 db.Nominativi.nome.represent = lambda nome,row: nome.title()

 db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)

 db.define_table('Relazioni',
 Field('nominativo',db.Nominativi,required=True,requires=[IS_IN_DB(db, 
 'Nominativi.id')]),
 Field('referente',db.Nominativi,required=True,requires=[IS_IN_DB(db, 
 'Nominativi.id')]),
 Field('tipo_relazione',label='Tipo di relazione'))

 db.Relazioni.tipo_relazione.widget = lambda field,value: \
  SQLFORM.widgets.string.widget(field,value,_placeholder=Inserire il 
 tipo di relazione)

 db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id,limitby=(0,10), min_length=3)


 db.define_table(Consulenze,
 Field('dentista',db.Nominativi,required=True),
 Field('data_inizio_collaborazione','date'),
 Field('data_fine_collaborazione','date'),
 Field('id_precedente','integer'),
 format=lambda r:db.Nominativi(r.dentista)['nome'])
 odontoiatri=db(db.Nominativi.categoria==2)

 db.Consulenze.dentista.requires=IS_IN_DB(odontoiatri,'Nominativi.id','%(nome)s')

 db.define_table(Pazienti_Consulenza,
 Field('dentista',db.Consulenze, required=True),
 Field('paziente',db.Nominativi,required=True, unique=True))

 everything worked fine when I've added the table.
 I can't see what is wrong in the last table ...

 Thx


-- 
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: foreign key constraint failed ???

2013-12-08 Thread 黄祥
had you already try using :
'reference Nominativi' instead of db.Nominativi 
and 
requires is set to db.Nominativi.id instead of 'Nominativi.id'?

e.g. 
db.define_table('Relazioni',
Field('nominativo', 'reference Nominativi', 
required=True,requires=[IS_IN_DB(db, db.Nominativi.id)]),
Field('referente', reference Nominativi', 
required=True,requires=[IS_IN_DB(db, db.Nominativi.id)]),
Field('tipo_relazione',label='Tipo di relazione'))

best regards,
stifan

-- 
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: foreign key constraint failed ???

2013-12-08 Thread Ivan Gazzola
I changed all fields in 'referece field' format but nothing changes :(
For the validatos IS_IN_DB(db,db.table.field,format) is mistaken and return 
errors, indeed the correct form is IS_IN_DB(db,table.field,format) ...

Regards

Ivan

Il giorno domenica 8 dicembre 2013 17:20:15 UTC+1, 黄祥 ha scritto:

 had you already try using :
 'reference Nominativi' instead of db.Nominativi 
 and 
 requires is set to db.Nominativi.id instead of 'Nominativi.id'?

 e.g. 
 db.define_table('Relazioni',
 Field('nominativo', 'reference Nominativi', 
 required=True,requires=[IS_IN_DB(db, db.Nominativi.id)]),
 Field('referente', reference Nominativi', 
 required=True,requires=[IS_IN_DB(db, db.Nominativi.id)]),
 Field('tipo_relazione',label='Tipo di relazione'))

 best regards,
 stifan


-- 
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: foreign key constraint failed ???

2013-12-08 Thread Ivan Gazzola
If possible I prefer to keep foreign_keys=True for db integrity.

Thx

Ivan

Il giorno domenica 8 dicembre 2013 15:41:03 UTC+1, Ivo ha scritto:

 though it may not be the preferred solution I resolved it by adding:
 adapter_args=dict(foreign_keys=False) to db = 
 DAL('sqlite://storage.sqlite') in db.py


 On Sunday, December 8, 2013 3:16:36 PM UTC+1, Ivan Gazzola wrote:

 I can't resolve this ticket in my app. I try to insert in 
 Pazienti_Consulenza from appadmin but i've always this error:
 
 class 'sqlite3.IntegrityError' foreign key constraint failed
 

 This is my model:

 db.define_table('Nominativi',
 Field('nome',notnull=True, represent=lambda nome:nome.title()),
 Field('categoria',db.Categorie_Nominativi,default='1'),
 Field('sesso',requires=IS_EMPTY_OR(IS_IN_SET(['maschio','femmina']))),
 Field('mail',requires=IS_EMPTY_OR(IS_EMAIL(error_message=T('Inserire 
 Una Mail Valida',
 Field('indirizzo'),
 Field('localita', label='Località'),
 Field('cap',requires=IS_EMPTY_OR(IS_LENGTH(5,5, 
 error_message=T('Inserire Un CAP valido',
 Field('provincia',requires=IS_EMPTY_OR(IS_IN_SET(Elenco_Province, 
 zero=T('Selezionare una Provincia',
 Field('codice_fiscale',length=20),
 Field('partita_iva',length=20),
 Field('data_di_nascita','date'),
 Field('professione'),
 Field('padre'),
 Field('madre'),
 Field('inviato_da'),
 Field('id_precendente','integer'),
 format=lambda 
 r:r.nome.title()+'--'+db.Categorie_Nominativi(r.categoria)['categoria'])

 db.Nominativi.nome.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.nome.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.mail.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.mail.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.indirizzo.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.indirizzo.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.localita.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.localita.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.cap.filter_in = lambda value : w2p_encrypt(value,key=chiave)
 db.Nominativi.cap.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.codice_fiscale.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.codice_fiscale.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.padre.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.padre.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)
 db.Nominativi.madre.filter_in = lambda value : 
 w2p_encrypt(value,key=chiave)
 db.Nominativi.madre.filter_out = lambda value : 
 w2p_decrypt(value,key=chiave)

 db.Nominativi.categoria.requires=IS_IN_DB(db,'Categorie_Nominativi.id','%(categoria)s',zero=None)
 db.Nominativi.categoria.represent = lambda id,row: row.categoria
 db.Nominativi.nome.represent = lambda nome,row: nome.title()

 db.Nominativi.inviato_da.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome)

 db.define_table('Relazioni',
 Field('nominativo',db.Nominativi,required=True,requires=[IS_IN_DB(db, 
 'Nominativi.id')]),
 Field('referente',db.Nominativi,required=True,requires=[IS_IN_DB(db, 
 'Nominativi.id')]),
 Field('tipo_relazione',label='Tipo di relazione'))

 db.Relazioni.tipo_relazione.widget = lambda field,value: \
  SQLFORM.widgets.string.widget(field,value,_placeholder=Inserire il 
 tipo di relazione)

 db.Relazioni.referente.widget=SQLFORM.widgets.autocomplete(request,db.Nominativi.nome,id_field=
 db.Nominativi.id,limitby=(0,10), min_length=3)


 db.define_table(Consulenze,
 Field('dentista',db.Nominativi,required=True),
 Field('data_inizio_collaborazione','date'),
 Field('data_fine_collaborazione','date'),
 Field('id_precedente','integer'),
 format=lambda r:db.Nominativi(r.dentista)['nome'])
 odontoiatri=db(db.Nominativi.categoria==2)

 db.Consulenze.dentista.requires=IS_IN_DB(odontoiatri,'Nominativi.id','%(nome)s')

 db.define_table(Pazienti_Consulenza,
 Field('dentista',db.Consulenze, required=True),
 Field('paziente',db.Nominativi,required=True, unique=True))

 everything worked fine when I've added the table.
 I can't see what is wrong in the last table ...

 Thx



-- 
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: foreign key constraint failed ???

2013-12-08 Thread Alan Etkin


 If possible I prefer to keep foreign_keys=True for db integrity.


Another similar thread 

https://groups.google.com/d/msg/web2py/klspqXpha4E/mCwQ6HC5IhAJ

-- 
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.