root / neighbors / model.py

Revision 128:5e724235253b, 0.6 kB (checked in by Tarek Ziad?? <tarek@…>, 15 months ago)

added db level

Line 
1import os
2from sqlalchemy import *
3from config import db
4
5curdir = os.path.dirname(__file__)
6if curdir == '':
7    curdir = '.'
8
9curdir = os.path.realpath(curdir)
10
11sql_db = create_engine(db)
12metadata = BoundMetaData(sql_db)
13
14distance = Table('neighbours_distance', metadata,
15                 Column('user', String(50)),
16                 Column('neighbour', String(50)),
17                 Column('distance', Float()))
18
19try:
20    distance.create()
21except exceptions.SQLError:
22    # already exists
23    pass
24
25def query(value):
26    return sql_db.execute(value).fetchall()
27
Note: See TracBrowser for help on using the browser.