A web2py and python newbie here.
I tried to do a sample web app with MySQL DB as backend DB. I have created a table in MySQL separately and populated with values and I want to display the table values in the UI. I have an error -
"class 'gluon.contrib.pymysql.err.InternalError'> (1050, u"Table '' already exists")"
My config files are below:
db.py
if not request.env.web2py_runtime_gae:
db = DAL('mysql://xxxxx',pool_size=1,check_reserved=['all'])
else:
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)
## after defining tables, uncomment below to enable auditing
# auth.enable_record_versioning(db)
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)
My home page look like this
{{ rows = db(db.user_details).select() }}
{{if len(rows):}}
<ul>
{{ for r in rows: }}
<li>
{{=r.name}}
</li>
{{pass}}
</ul>
{{pass}}
I am not sure what I am missing. Any help appreciated, thanks.
I got it now. Just had to change migrate=False. Thanks.