Hi everyone
Let's say I have a database that I want to fit a web application to. There
are a lot of views and triggers in the database, so I do not consider
porting as a viable option. How do I go about doing this?
My steps are as follow:
1. create an "init" application
2. put my database into application/init/controller folder
3. I have the following as controller/default.py
import sqlite3 as s
con = s.connect('nat_full.db')
cur = con.cursor()
def get_average_microarray():
form = FORM(
TABLE(
TR('Organism: ',
SELECT('Human', 'Mouse', 'Rat', _name='organism')),
TR('Level: ',
SELECT('Gene', 'Exon', _name='level')),
TR('Type: ',
SELECT('Sense', 'Antisense', _name='type')),
INPUT(_type='submit', _value='SUBMIT')))
if form.accepts(request.vars,session):
session.organism = str(form.vars.organism)
session.level = str(form.vars.level)
session.type = str(form.vars.type)
redirect(URL(r=request, f='show_average_microarray'))
return dict(form=form)
def show_average_microarray():
tablename = ''
if session.level == 'Gene' and session.type == 'Sense':
tablename = 'sense_gene_core_table'
elif session.level == 'Gene' and session.type == 'Antiense':
tablename = 'antisense_gene_core_table'
elif session.level == 'Exon' and session.type == 'Sense':
tablename = 'sense_exon_core_table'
elif session.level == 'Exon' and session.type == 'Antiense':
tablename = 'antisense_exon_core_table'
stmt = 'select * from ' + tablename
cur.execute(stmt)
result = cur.fetchall()
return dict(result=result)
4. http://localhost:8000/init/default/get_average_microarray shows the
primitive form (which is alright) but it gives me an error when I submit
the form.
Traceback (most recent call last):
File "C:\Users\Maurice.Ling\Desktop\nat_web\gluon\restricted.py", line 212,
in restricted
exec ccode in environment
File
"C:/Users/Maurice.Ling/Desktop/nat_web/applications/init/controllers/default.py"
<http://localhost:8000/admin/default/edit/init/controllers/default.py>, line
48, in <module>
File "C:\Users\Maurice.Ling\Desktop\nat_web\gluon\globals.py", line 188, in
<lambda>
self._caller = lambda f: f()
File
"C:/Users/Maurice.Ling/Desktop/nat_web/applications/init/controllers/default.py"
<http://localhost:8000/admin/default/edit/init/controllers/default.py>, line
45, in show_average_microarray
cur.execute(stmt)
OperationalError: no such table: sense_gene_core_table
Is there any solution?
Thanks in advance
Maurice
--