Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/mauRepo/MolesManager/trunk/src/MolesManager/dataaccess.py@8014
Revision 8014,
1016 bytes
checked in by mnagni, 9 years ago
(diff) |
The tables are correctly generated and the migration does not show major problem. Good!
|
Line | |
---|
1 | ''' |
---|
2 | Created on 3 Nov 2011 |
---|
3 | |
---|
4 | @author: mnagni |
---|
5 | ''' |
---|
6 | from MolesManager.settings import MOLES3DB |
---|
7 | from ea_model.iso_19103_2005_schema_language.basic_types.primitive.date_and_time.date import Date |
---|
8 | from ea_model.ceda_moles.ceda_observation.ceda_observation import CEDA_Observation |
---|
9 | |
---|
10 | |
---|
11 | def _buildFilter(key, keyValue): |
---|
12 | return '%s = \'%s\'' % (key, keyValue) |
---|
13 | |
---|
14 | def _checkSession(session): |
---|
15 | if session is None: |
---|
16 | return MOLES3DB.getSession() |
---|
17 | else: |
---|
18 | return session |
---|
19 | |
---|
20 | def doInsert(toStoreInstance, session = None): |
---|
21 | session = _checkSession(session) |
---|
22 | session.add(toStoreInstance) |
---|
23 | session.commit() |
---|
24 | |
---|
25 | def getCEDA_ObservationById(id, session = None): |
---|
26 | session = _checkSession(session) |
---|
27 | res = session.query(CEDA_Observation).filter(*[_buildFilter('mo_observation_id', id)]) |
---|
28 | print(res) |
---|
29 | return res.all() |
---|
30 | |
---|
31 | def getDateById(id, session = None): |
---|
32 | session = _checkSession(session) |
---|
33 | res = session.query(Date).filter(*[_buildFilter('date_id', id)]) |
---|
34 | print(res) |
---|
35 | return res.all() |
---|
Note: See
TracBrowser
for help on using the repository browser.