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
 try to load up the

[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 
>>>
>>> 127.0.0.1.2017-07-02.10-06-22.18c363e3-13c2-47f7-ac

[web2py] Re: FOREIGN KEY constraint failed

2017-07-04 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 "/home/mos

[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, sessi

[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 constrain

[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 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 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+unsubscr...@

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 :

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


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


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 :

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


[web2py] Re: (foreign key constraint failed)

2015-02-18 Thread Anthony
Did this solve your problem?

On Wednesday, February 18, 2015 at 5:07:02 AM UTC-5, Smruti Prakash Mohanty 
wrote:
>
> Hi
>
> I am using the web2py default auth table for user registration.
>
> I am having an additional table defined as such:
>
> db.define_table('nsksystem',
> Field('email_id', db.auth_user,length=512, label = 'Email 
> ID'),
> Field('nskname', length=128, default='', label = 'Machine 
> Name'),
> Field('nskpassword', 'password', 
> length=512,readable=False, label='Machine Password'),
> Field('confirmnskpassword', 'password', 
> length=512,readable=False, label='Confirm Machine Password'),
> Field('nreleaseid',length=128, default='',label = 
> 'Release'),
> Field('isCordinator','boolean',default='', label = 'Is 
> Co-ordinator'))
>
>
> db.nsksystem.email_id.requires = 
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> db.nsksystem.email_id.requires = IS_IN_DB(db,'auth_user.email','%(email)s')
> db.nsksystem.nreleaseid.requires = 
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> db.nsksystem.nskname.requires = 
> IS_NOT_EMPTY(error_message=auth.messages.is_empty)
> db.nsksystem.confirmnskpassword.requires = IS_EXPR('value==%s' % 
> repr(request.vars.get('nskpassword', None)),error_message='Passwords do not 
> match')
> db.nsksystem.isCordinator.requires=IS_NOT_IN_DB(db(db.nsksystem.nreleaseid 
> == request.vars.nreleaseid), 'nsksystem.isCordinator', 
> error_message='Co-ordinator Already exist for specified release')
>
> In my Controller:
>
> def uregistration(): ##---> For my user registration
> form=SQLFORM(db.auth_user)
> if form.process().accepted:
> response.flash = 'User is registered. Redirecting to machine 
> registration'
> redirect(URL('mregistration')) #-> After registration it goes 
> to another page for machine registration.
> elif form.errors:
> response.flash = 'Form has errors'
> else:
> response.flash = 'Please fill out the form'
> return dict(form=form)
>
>
> def mregistration():  ##---> for machine registration page
> form=SQLFORM(db.nsksystem) 
> if form.process().accepted:
> response.flash = 'Machine is registered to user. Please go to 
> Login page.'
> redirect(URL('index'))
> elif form.errors:
> response.flash = 'Form has errors'
> else:
> response.flash = 'Please fill out the form'
> return dict(form=form)
>
> Now after I have registered the user, i am being redirected to Machine 
> registration page. After i enter all the details in Machine registration 
> page I get this error:
>
> Traceback (most recent call last):
>   File "gluon/restricted.py", line 224, in restricted
>   File "C:/web2py/applications/click/controllers/default.py" 
> , line 
> 63, in 
>   File "gluon/globals.py", line 393, in 
>   File "C:/web2py/applications/click/controllers/default.py" 
> , line 
> 30, in mregistration
> if form.process().accepted:
>   File "gluon/html.py", line 2303, in process
>   File "gluon/html.py", line 2240, in validate
>   File "gluon/sqlhtml.py", line 1677, in accepts
>   File "gluon/dal/objects.py", line 724, in insert
>   File "gluon/dal/adapters/base.py", line 715, in insert
> IntegrityError: foreign key constraint failed
>
> Error snapshot  (foreign key constraint 
> failed)  
>   Function argument list
>   
> (self=, 
> table= (id,email_id,nskname,nskpassword,confirmnskpassword,nreleaseid,isCordinator)>,
>  fields=[(, '123456'), 
> (, 'vodka.ind.codefactory.com'), 
> (, 0), 
> (, True), 
> (, 'AAA'), 
> (, '123456')])
>
>
> I wonder why i dont see the email address that i select in the machine 
> registration page. (, 0) in the Function 
> argument list refers to email id or only ID.
>
> I am confused. Unfortunately i cant turn the constraint validation off as it 
> is a requirement.
> 
>

-- 
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-02-18 Thread Niphlod
a little bit of wording around "unfortunately I can't turn off"

it's not that having constraints in place is limiting your app. It's 
because something REAALLY wrong with your application that that error pops 
up (and it'll pop up with any other backend). I'd be more inclined to say 
"thanks a lot web2py, I can't turn it off, or else, I'm going to be really 
screwed once I put this on production".

Back on topic

Field('email_id', db.auth_user,length=512, label = 'Email ID')

this is a FK to the field *id* of the table *auth_user*. length doesn't 
obviously go there (as it's an integer) and the validation you're imposing 
is totally wrong

db.nsksystem.email_id.requires = IS_IN_DB(db,'auth_user.email','%(email)s') 

Are you sure you planned your model the way you're supposed to use it ? 
IMHO you're expecting that field to contain an email, not an id.

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

2014-09-26 Thread Cliff Kachinske
This post on StackOverflow may help 
http://stackoverflow.com/questions/9636053/is-there-a-way-to-get-the-constraints-of-a-table-in-sqlite

There is a code snippet you might try.

On Monday, September 22, 2014 5:01:11 PM UTC-4, Anna Kostikova wrote:
>
> Hi everyone,
>
> I am having an issue when editing content of one of the tables in my 
> database. When I try to edit a record in the table I have an error message 
> " foreign key constraint failed". The 
> bizarre thing is that it doesn't matter which column I am trying to edit 
> (via appadmin control panel) - i have exactly same message. For instance, I 
> have a column "description" that doesn't have any keys on it (or 
> references), but I can't edit the content of this field and I keep getting 
> the error above.
>
> What might be causing the issue?
> I am using python 2.7.7 and web2py 2.9.5
>
> Thanks
> Anna
>

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

2014-09-24 Thread Leonel Câmara
Seems like a botched migration to me. Can you tell me what changes you made 
to your model, and a sample of the data you had there before?

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


[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:
>> "
>>  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+u

[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 黄祥
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 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:
> "
>  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.