If you benefit from web2py hope you feel encouraged to pay it forward by contributing back to society in whatever form you choose!

help with mysql, I'm trying to connect to a new mysql database with movuca, and I get this error

I'm using pythonanywhere

https://github.com/rochacbruno/Movuca/blob/master/modules/datamodel/setup.py

 

<class '_mysql_exceptions.IntegrityError'> (1452, 'Cannot add or update a child row: a foreign key constraint fails (`samuel$mydb`.`article_category`, CONSTRAINT `article_category_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `article_category` (`id`) ON DELETE CASCADE)')

 

 

Traceback (most recent call last):
  File "/home/samuel/web2py/gluon/restricted.py", line 212, in restricted
    exec ccode in environment
  File "/home/samuel/web2py/applications/social/controllers/home.py", line 34, in <module>
  File "/home/samuel/web2py/gluon/globals.py", line 188, in <lambda>
    self._caller = lambda f: f()
  File "/home/samuel/web2py/applications/social/controllers/home.py", line 17, in index
    home = Home(['featured', 'featured_members', 'homeblocks', 'articles'])
  File "applications/social/modules/handlers/base.py", line 32, in __init__
    self.start()
  File "applications/social/modules/handlers/home.py", line 12, in start
    self.db = DataBase([User, ContentType, Category, Article, Ads, Page])
  File "applications/social/modules/movuca.py", line 45, in __init__
    self.define_classes(classes)
  File "applications/social/modules/movuca.py", line 51, in define_classes
    obj = cls(self)
  File "applications/social/modules/basemodel.py", line 51, in __init__
    self.pre_load()
  File "applications/social/modules/basemodel.py", line 111, in pre_load
    self.__getattribute__(method)()
  File "applications/social/modules/datamodel/article.py", line 192, in set_fixtures
    content_type=self.db(self.db.content_type.identifier == 'Article').select().first().id
  File "/home/samuel/web2py/gluon/dal.py", line 7806, in insert
    ret =  self._db._adapter.insert(self,self._listify(fields))
  File "/home/samuel/web2py/gluon/dal.py", line 1161, in insert
    raise e
IntegrityError: (1452, 'Cannot add or update a child row: a foreign key constraint fails (`samuel$mydb`.`article_category`, CONSTRAINT `article_category_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `article_category` (`id`) ON DELETE CASCADE)')

 

help me please ?

 

Answers (3)

Comments (3)

  • Login to post



  • 0
    samuel-bonilla-11088 11 years ago

    the error is generated when i change setup.py , example:

    
    
    1. class Setup(object):
    2.  
    3. def __init__(self):
    4. T = current.T
    5. self.db_options = [
    6. Field("uri", "string", notnull=True, default="mysql://my_username:my_password@localhost/my_dbname"),
    7. Field("migrate", "boolean", notnull=True, default=True),
    8. Field("migrate_enabled", "boolean", notnull=True, default=True),
    9. Field("pool_size", "integer", notnull=True, default=10),
    10. Field("gaeuri", "string", notnull=True, default="google:datastore"),
    11. Field("setuptime", "datetime", notnull=True),
    12. ]

    then :

    controler

    setup.py  install

    and i get the error


  • 0
    rochacbruno 11 years ago

    I will try here and if I find the solution I will post here, BW, I have some changes to commit to Movuca. IMprovements.

     

    I have MOvuca running on Mysql and Postgres and I did not have this problem.

     

    When the error occurs? on /setup or after the setup when you go to home page?

    replies (1)
    • josedesoto 11 years ago

      Hi,

      If I change only the file movuca/modules/config.py to connect to MySql and after I open the install URL. It looks works fine. But I can see tables in Mysql and in SQlite. For example the auth tables and article_category table are in SQLite.

      If I change the file config.py and setup.py to connects to MySql, and after I open the install URL. I get the error. It looks Movuca try to create the auth tables, article_category, etc in Mysql. I have seen in this case, Movuca creates as well the tables in SQLite.


  • 1
    josedesoto 11 years ago

    I have tested it in my computer with a local Mysql and I get the same error... In SQLite works fine.

Related content


Hosting graciously provided by:
Python Anywhere