source: mauRepo/MolesManager/trunk/src/MolesManager/dataaccess.py @ 8054

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/MolesManager/dataaccess.py@8054
Revision 8054, 710 bytes checked in by mnagni, 8 years ago (diff)

Deep refactoring of the DB Connection. Now the there are
1) a PJB concentrating all the migration DB actions and managing their sessions
2) a Middleware doing a similar thing for the Django application

Line 
1'''
2Created on 3 Nov 2011
3
4@author: mnagni
5'''
6from ea_model.iso_19103_2005_schema_language.basic_types.primitive.date_and_time.date import Date
7from ea_model.ceda_moles.ceda_observation.ceda_observation import CEDA_Observation
8from sqlalchemy.orm.util import class_mapper
9
10def _buildFilter(key, keyValue):
11    return '%s = \'%s\'' % (key, keyValue)
12
13def doInsert(toStoreInstance, session):
14    session.add(toStoreInstance)
15    session.commit()
16
17def getCEDA_ObservationById(id, session):   
18    res = session.query(CEDA_Observation)
19    print(res)
20    return res.all()
21
22def getDateById(id, session):     
23    res = session.query(Date).filter(*[_buildFilter('date_id', id)])
24    print(res)
25    return res.all()
Note: See TracBrowser for help on using the repository browser.