[web2py] Re: web2py 1.90.1 is OUT
thanks thats got fix,if i nesrt any value ,i am getting below error RACEBACK 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. Traceback (most recent call last): File "/home/sushanth/Desktop/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 53, in File "/home/sushanth/Desktop/web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 13, in index if form.accepts(request,session): File "/home/sushanth/Desktop/web2py/gluon/sqlhtml.py", line 1159, in accepts self.vars.id = self.table.insert(**fields) File "/home/sushanth/Desktop/web2py/gluon/dal.py", line 3759, in insert return self._db._adapter.insert(self,self._listify(fields)) File "/home/sushanth/Desktop/web2py/gluon/dal.py", line 703, in insert raise e IntegrityError: (1452, u'Cannot add or update a child row: a foreign key constraint fails (`new`.`users`, CONSTRAINT `users_ibfk_1` FOREIGN KEY (`team`) REFERENCES `dogs` (`teamname`))') Can you please look into it.
[web2py] Re: web2py 1.90.1 is OUT
db=DAL('mysql://root:test1234...@localhost/new') db.define_table('dogs', Field('id'), Field('teamname'),primarykey=['teamname'],migrate=True ) db.define_table('users', Field('name'), Field('team',db.dogs) ) db.users.name.requires = IS_NOT_EMPTY() db.users.team.requires = IS_IN_DB(db, 'dogs.teamname', '%(dogs.teamname)') sql.log timestamp: 2010-12-20T22:39:05.866199 CREATE TABLE dogs( teamname VARCHAR(100) NOT NULL, PRIMARY KEY(teamname)) ENGINE=InnoDB CHARACTER SET utf8; success! timestamp: 2010-12-20T22:39:05.968109 CREATE TABLE users( id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100), team VARCHAR(100), INDEX team__idx (team), FOREIGN KEY (team) REFERENCES dogs(teamname), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; success! def index(): form=SQLFORM(db.users) if form.accepts(request,session): response.flash='new record inserted' records=SQLTABLE(db().select(db.users.ALL)) return dict(form=form,records=records) I am able to create fk now with string,but if i insert any values into dogs table and refersh the page it throws error error : Traceback (most recent call last): File "/home/sushanth/Desktop/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 64, in File "/home/sushanth/Desktop/web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/default.py" <http://127.0.0.1:8000/admin/default/edit/welcome/controllers/default.py>, line 12, in index form=SQLFORM(db.users) File "/home/sushanth/Desktop/web2py/gluon/sqlhtml.py", line 792, in __init__ inp = self.widgets.options.widget(field, default) File "/home/sushanth/Desktop/web2py/gluon/sqlhtml.py", line 205, in widget options = requires[0].options() File "/home/sushanth/Desktop/web2py/gluon/validators.py", line 424, in options self.build_set() File "/home/sushanth/Desktop/web2py/gluon/validators.py", line 419, in build_set self.labels = [self.label % dict(r) for r in records] KeyError: 'dogs.teamname' I think there is an issue with new dal.py with pymsql. can you please help me on this. Thanks sushanth
[web2py] Error while updating the form
Getting below error while inserting a records through form. When i insert same values in mysql console it works.i have found that it looks like FK constraint,but schema looks fine. Can you please help on this, Traceback (most recent call last): File "/var/www/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/var/www/web2py/applications/new/controllers/default.py", line 54, in File "/var/www/web2py/gluon/globals.py", line 95, in self._caller = lambda f: f() File "/var/www/web2py/applications/new/controllers/default.py", line 13, in index if form.accepts(request): File "/var/www/web2py/gluon/sqlhtml.py", line 1159, in accepts self.vars.id = self.table.insert(**fields) File "/var/www/web2py/gluon/dal.py", line 3751, in insert return self._db._adapter.insert(self,self._listify(fields)) File "/var/www/web2py/gluon/dal.py", line 701, in insert raise e IntegrityError: (1452, u'Cannot add or update a child row: a foreign key constraint fails (`master`.`logistics`, CONSTRAINT `logistics_ibfk_1` FOREIGN KEY (`vendor`) REFERENCES `name_config` (`company`))') Thanks sushanth
[web2py] Re: web2py 1.90.1 is OUT
Found mysql two issues in new dal.py First issues mysql VARCHAR length should be 0 to 255,but web2py default varchar value was set to length = 512,if some forgot to declare varchar length he will get error message key too long. Second issue After creating FK in the model if we declare db.define_table('dogs', Field('teamname'),primarykey=['teamname'],migrate=False ) db.define_table('users', Field('name'), Field('team',db.dogs) ) db.users.name.requires = IS_NOT_EMPTY() db.users.team.requires = IS_IN_DB(db,'dogs.teamname','dogs.teamname') sql : CREATE TABLE users( id INT AUTO_INCREMENT NOT NULL, name VARCHAR(100), team id, INDEX team__idx (team), FOREIGN KEY (team) REFERENCES dogs(teamname), PRIMARY KEY(id) ) ENGINE=InnoDB CHARACTER SET utf8; Here teamname was set to string and team in the user table goes interger ,then it throws error 1005 can't create table users 'reference': 'INT, INDEX %(field_name)s__idx (%(field_name)s), FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', as wrokaround i have changed the dal file to 'reference': 'VARCHAR(100), INDEX %(field_name)s__idx (%(field_name)s), FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', then it works.
Re: [web2py] Need help
Sorry typo mistake dogs.teamname is defined.
Re: [web2py] Need help
Sorry typo mistake dogs.names is defined.
Re: [web2py] Need help
Hi Kenneth, Current web2py using : 1.90.2 Yes,i have tried.
[web2py] Need help
Hi, Can any one help on this issue. https://groups.google.com/forum/#!topic/pymysql-users/vrnKcoE6ZD0 Thanks sushanth
[web2py] Re: Unable to detect your browser
On ubuntu you can change your defualt browser with below steps susha...@ubuntu:~$ sudo update-alternatives --config x-www-browser [sudo] password for sushanth: There are 2 choices for the alternative x-www-browser (providing /usr/bin/x-www-browser). SelectionPathPriority Status * 0/usr/bin/google-chrome 150 auto mode 1/usr/bin/firefox 40manual mode 2/usr/bin/google-chrome 150 manual mode Press enter to keep the current choice[*], or type selection number:
[web2py] Re: KeyError: 'users'
Nope, its not working I have posted the issue in pymsql group. if possible can you please add mysql documentation on web2py site. coz most of the web application are designed in mysql i didn't much documentation. right now i am finding most of the content sqllite. Thank for the support. Regards, sushanth reddy
[web2py] Re: web2py 1.90.1 is OUT
web2py team rocks :)
[web2py] Re: KeyError: 'users'
if possible,can you please small mysql example for creating FK for string field with dal.py. this example will help me lot in fix key issue. Thanks in advance
[web2py] Re: KeyError: 'users'
I am using new dal.py file from trunk,but it throws below error Traceback (most recent call last): File "/home/sushanth/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/sushanth/web2py/applications/new/models/db.py" <http://127.0.0.1:8000/admin/default/edit/new/models/db.py>, line 74, in Field("status", "string", default='A')) File "/home/sushanth/web2py/gluon/dal.py", line 3310, in define_table self._adapter.create_table(t,migrate=migrate, File "/home/sushanth/web2py/gluon/dal.py", line 525, in create_table self.create_sequence_and_triggers(query,table) File "/home/sushanth/web2py/gluon/dal.py", line 1048, in create_sequence_and_triggers self.execute(query) File "/home/sushanth/web2py/gluon/dal.py", line 1055, in execute return self.log_execute(*a, **b) File "/home/sushanth/web2py/gluon/dal.py", line 1052, in log_execute return self.cursor.execute(*a,**b) File "/home/sushanth/web2py/gluon/contrib/pymysql/cursors.py", line 102, in execute self.errorhandler(self, exc, value) File "/home/sushanth/web2py/gluon/contrib/pymysql/cursors.py", line 97, in execute result = self._query(query) File "/home/sushanth/web2py/gluon/contrib/pymysql/cursors.py", line 179, in _query conn.query(q) File "/home/sushanth/web2py/gluon/contrib/pymysql/connections.py", line 578, in query self._affected_rows = self._read_query_result() File "/home/sushanth/web2py/gluon/contrib/pymysql/connections.py", line 665, in _read_query_result result.read() File "/home/sushanth/web2py/gluon/contrib/pymysql/connections.py", line 822, in read self.first_packet = self.connection.read_packet() File "/home/sushanth/web2py/gluon/contrib/pymysql/connections.py", line 660, in read_packet packet.check_error() File "/home/sushanth/web2py/gluon/contrib/pymysql/connections.py", line 323, in check_error raise_mysql_exception(self.__data) File "/home/sushanth/web2py/gluon/contrib/pymysql/err.py", line 132, in raise_mysql_exception _check_mysql_exception(errinfo) File "/home/sushanth/web2py/gluon/contrib/pymysql/err.py", line 128, in _check_mysql_exception raise InternalError, (errno, errorvalue) InternalError: (1005, u"Can't create table 'geomaster.geo_logistics' (errno: 150)")
[web2py] Re: KeyError: 'users'
I have added below lines to gluon/sql.py,but stil getting same error 'reference FK': 'INDEX %(field_name)s__idx (%(field_name)s), FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_key)s ON DELETE %(on_delete_action)s', 'reference TFK': ' INDEX %(field_name)s__idx (%(field_name)s), FOREIGN KEY (%(field_name)s) REFERENCES %(foreign_table)s (%(foreign_key)s) ON DELETE %(on_delete_action)s',
[web2py] KeyError: 'users'
Hi, How to create a primary key as name as filed not id,right now i have exiting mysql schema in that string is PK and connected FK to other string field.i am design a app in web2py in that creating models using existing schema but web2py is creating only id as PK default. Can you please help on this db=DAL('mysql://root:test1234...@localhost/new') db.define_table('dogs', Field('owner_id','id'), Field('teamname'),primarykey=['owner_id','teamname'], migrate=False, ) db.define_table('users', Field('num','id'), Field('name'), Field('team',db.users),primarykey=['num','team'], migrate=False, ) db.users.name.requires = IS_NOT_EMPTY() db.users.team.requires = IS_IN_DB(db, 'dogs.teamname', ' dogs_teamname') error : Traceback (most recent call last): File "/home/sushanth/Desktop/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/sushanth/Desktop/web2py/applications/newone/models/db.py" <http://127.0.0.1:8000/admin/default/edit/newone/models/db.py>, line 13, in Field('team',db.users),primarykey=['num','team'], File "/home/sushanth/Desktop/web2py/gluon/sql.py", line 1400, in __getattr__ return dict.__getitem__(self,key) KeyError: 'users' Thanks in advance
[web2py] Re: How to fetch already exiting table data with out defining new table
Thank you for the info, i am doing the same.but only problem i found i am not able to run return dict(records=db().select(db.tablename.ALL)) it throws below error Traceback (most recent call last): File "/home/sushanth/Desktop/web2py/gluon/restricted.py", line 188, in restricted exec ccode in environment File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/ default.py", line 104, in File "/home/sushanth/Desktop/web2py/gluon/globals.py", line 96, in self._caller = lambda f: f() File "/home/sushanth/Desktop/web2py/applications/welcome/controllers/ default.py", line 66, in contacts return dict(records=db().select(db.gtmaster.ALL)) File "/home/sushanth/Desktop/web2py/gluon/sql.py", line 1400, in __getattr__ return dict.__getitem__(self,key) KeyError: 'tablename' On Dec 16, 11:47 pm, pbreit wrote: > Here's one:https://groups.google.com/d/topic/web2py/mH5Toup0vwk/discussion
[web2py] How to fetch already exiting table data with out defining new table
Hi, I already have few tables with data in mysql.i want to fetch that with out defining in model.py. can you please help me. Thanks in advance Regards, sushanth