Question
This semester, I am doing a web application. My task is to create a web service that will connect my sqlite database to the web
This semester, I am doing a web application. My task is to create a web service that will connect my sqlite database to the web application. I have created the sqlite database and wrote the code to return all the data from my database in python. I need to create a web service that return all user information in an url. The data should be return in json format. Besides that I also need to build a web service that return the user's name, location and title in an url. I need it done by today's midnight. Here is the link of a sample of the webservice :http://www.dreamsyssoft.com/python-scripting-tutorial/create-simple-rest-web-service-with-python.php For now , I know how to import the sqlite data in python. But I don't know how to make it as a function in python so that it will create the url. i have attached the code of both web service and the sqlite database.
1 this is my code for importing the data from the database in python.
mport sqlite3
connection = sqlite3.connect('userdata.db-2.sqlite')
cursor = connection.cursor()
sql_query = "SELECT * FROM user"
rows = cursor.execute(sql_query)
for row in rows: print("User Information") print "Name -> " + row[0] print "Title -> " + row[1] print "Email -> " + row[2] print "Phone -> " + row[3] print "Location -> " + row[4] print ""
connection.close()
2 this is my code for selecting only the location and user name from the database.
mport sqlite3
connection = sqlite3.connect('userdata.db-2.sqlite')
cursor = connection.cursor()
sql_query = "SELECT name, title, location FROM user"
rows = cursor.execute(sql_query)
for row in rows: print("User Information") print "Name -> " + row[0] print "Title -> " + row[1] print "Location -> " + row[2] print ""
connection.close()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started