Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 2_OrientDB #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions pyorientAssignment.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

import pyorient
import sys

client = pyorient.OrientDB("localhost", 2424)
session_id = client.connect("root", "admin")
session_id = client.connect("root", "474F1CBE549F9E33FC8A0793C7819485072DAE07A4B704138010F28A28B69DF9")
db_name = "soufun"
db_username = "admin"
db_password = "admin"
Expand All @@ -15,11 +14,11 @@
print "database [" + db_name + "] does not exist! session ending..."
sys.exit()

lat1 = 22.532498
lat2 = 22.552317
lat1 = 22.536870
lat2 = 22.553872

lng1 = 114.044329
lng2 = 114.076644
lng1 = 114.026551
lng2 = 114.060868

query = 'SELECT FROM Listing WHERE latitude BETWEEN {} AND {} AND longitude BETWEEN {} AND {}'

Expand All @@ -40,10 +39,26 @@
print record.price


s = 0
for record in records:
s += record.price


miNum = 10000000
for record in records:
if record.price < miNum:
miNum = record.price

maNum = 50
for record in records:
if record.price > maNum:
maNum = record.price


# [PRINT OUT THE RESULTING VALUES BY CONCATENATING THEM TO THESE LINES TO CHECK YOUR WORK]

print 'min price: '
print 'max price: '
print 'average price: '
print 'min price: '+ str(miNum)
print 'max price: '+ str(maNum)
print 'average price: '+ str(s/numListings)

client.db_close()