Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import sqlite3
import cherrypy
import json
class ExposeRealStateDB(object):
app = '/tmp/propertyRS.db'
@cherrypy.expose
def getproperty(self, id):
return json.dumps(str(self.getPropertyId(id)))
#return 'Property is'
def getPropertyId(self, post_id):
db = self.connect_db()
sql = 'select property.id, price, typeprop, contract, location, state, description, image.path from property inner join image on property.id = image.property_id where property.id=' + post_id
print sql
cur = db.execute(sql)
propertyRecords = [dict(id=row[0], price=row[1], type=row[2], contract=row[3] , location=row[4], state=row[5], description=row[6], imagetodisplay=row[7]) for row in cur.fetchall()]
print propertyRecords
db.close()
return propertyRecords
def connect_db(self):
return sqlite3.connect(ExposeRealStateDB.app)
if __name__=='__main__':
cherrypy.quickstart(ExposeRealStateDB())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment