Got it. It worked now. Thanks.



On Friday, October 18, 2013 1:31:11 PM UTC-4, Vj wrote:
>
> All,
>
> A new web2py & python user here.
>
> I am trying to build a sample webapp using web2py. My plan is to use MySQL 
> DB (tables already created with data). I want to retrieve data from the 
> table from MySQL and display on the home page. I have errors when doing 
> that - 
> <class 'gluon.contrib.pymysql.err.InternalError'> (1050, u"Table 
> 'user_details' already exists")
>
> My Config files are below
>
> db.py
>
> # -*- coding: utf-8 -*-
> if not request.env.web2py_runtime_gae:
>     ## if NOT running on Google App Engine use SQLite or other DB
>     ##db = 
> DAL('sqlite://storage.sqlite',pool_size=1,check_reserved=['all'])
>     db = DAL('mysql://xxxxxxx',pool_size=1,check_reserved=['all'])
> else:
>     ## connect to Google BigTable (optional 
> 'google:datastore://namespace')
>     db = DAL('google:datastore')
>     ## store sessions and tickets there
>     session.connect(request, response, db=db)
>
> response.generic_patterns = ['*'] if request.is_local else []
>
> from gluon.tools import Auth, Crud, Service, PluginManager, prettydate
> auth = Auth(db)
> crud, service, plugins = Crud(db), Service(), PluginManager()
>
> ## create all tables needed by auth if not custom tables
> auth.define_tables(username=False, signature=False)
>
> db.define_table('user_details',
>     Field('user_id', 'text'),
>     Field('first_name', 'text'),
>     Field('last_name', 'text'),
>     Field('city', 'text'),
>     Field('user_st', 'text'),migrate=True)
>
> I have the table user_details created already in MySQL. I want to display 
> the information of all the records from the table.
>
>
> My home page code is 
>
> {{ rows = db(db.user_details).select() }}
> {{if len(rows):}}
> <ul>
> {{ for r in rows: }}
>   <li>
>
>         {{=r.name}}
>     
>   </li>
> {{pass}}
> </ul>
> {{pass}}
>
> I am not able to find out the issue. Any help appreciated. Thanks.
>
>
>

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

Reply via email to