I have been working with sqlite DB for some time but want to integrate my codes to web2py esp. DAL. How do I rewrite such a code to web2py DAL code?
name = input ('Please Type your Question: ').lower().split()
name2 = name[:]
import sqlite3
for item in name2:#break
conn = sqlite3.connect("foods.db")
cursor = conn.cursor()
cursor.execute("INSERT INTO INPUT33 (NAME) VALUES (?);", (name2,))
cursor.execute("select MAX(rowid) from [input33];")
conn.commit()
for rowid in cursor:break
for elem in rowid:
m = elem
print(m)
cursor.execute("DELETE FROM INPUT33 (NAME) WHERE NAME = name")
I do not quite understand the question so I would like to apologize in advance for any misunderstanding.
Web2py is a Web MVC framework and you should follow that pattern while designing your application. Having that in mind, using a console-related function like
input
makes no sense. Also, you shouldn't use the same component to extract user interaction related data and deal with database connection and data access/manipulation.If your intent is to simply convert your code snippet that used sqlite3 module into using pyDAL you just need to install it
pip install pydal
and change your code to something likeA full documentation can be found here