Commit b6e774ba authored by Krishnakant Mane's avatar Krishnakant Mane
Browse files

added REST resource for organisation

parent b663ba9a
......@@ -29,8 +29,11 @@ Contributor:
Main entry point"""
from pyramid.config import Configurator
from gkcore.models.meta import dbconnect, meta
eng = dbconnect()
def main(global_config, **settings):
config = Configurator(settings=settings)
......@@ -24,5 +24,4 @@ Contributor:
"Ishan Masdekar " <>
"Navin Karkera" <>
from gkdb import organisation
\ No newline at end of file
import gkdb
\ No newline at end of file
......@@ -40,12 +40,13 @@ from sqlalchemy import (
Unicode, #<- will provide Unicode field
UnicodeText, #<- will provide Unicode text field
MetaData #<- time abstraction field
#<- time abstraction field
from sqlalchemy.sql.schema import ForeignKey
from sqlalchemy.sql.sqltypes import BOOLEAN, Numeric
from gkcore.models.meta import meta
metadata = MetaData()
metadata = meta
organisation = Table( 'organisation' , metadata,
Column('orgcode',Integer, primary_key=True),
......@@ -129,6 +130,6 @@ BankRecon=Table('bankrecon',metadata,
orgcode = Column(Integer, ForeignKey('organisation.orgcode')),
Column('orgcode',Integer, ForeignKey('organisation.orgcode')),
\ No newline at end of file
......@@ -25,10 +25,9 @@ Contributor:
"Navin Karkera" <>
from gkcore.models.meta import dbconnect, Base
from gkcore.models.meta import dbconnect, meta
meta = Base.metadata
eng = dbconnect()
eng.execute("alter table groupsubgroups add foreign key (subgroupof) references groupsubgroups(groupcode)")
......@@ -25,19 +25,13 @@ Contributor:
"Ishan Masdekar " <>
"Navin Karkera" <>
from sqlalchemy.orm import (
from zope.sqlalchemy import ZopeTransactionExtension
from sqlalchemy.engine import create_engine
DBSession = scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
from sqlalchemy.engine import create_engine, Engine
from sqlalchemy import MetaData
meta = MetaData()
def dbconnect():
stmt = 'postgresql+psycopg2:///gkdata?host=/var/run/postgresql'
#now we will create an engine instance to connect to the given database.
#engine = Engine
engine = create_engine(stmt, echo=False)
return engine
from cornice.resource import resource, view
from gkcore import eng
from gkcore.models import gkdb
from sqlalchemy.sql import select
import json
from sqlalchemy.engine.base import Connection
con = Connection
con = eng.connect()
class api_organisation(object):
def __init__(self,request):
self.request = request
def collection_get(self):
result = con.execute(select([gkdb.organisation.c.orgcode, gkdb.organisation.c.orgname, gkdb.organisation.c.orgtype]))
orgs = []
for row in result:
orgs.append({"orgcode":row["orgcode"], "orgname":row["orgname"], "orgtype":row["orgtype"] })
print orgs
return orgs
@view(renderer='json', accept='text/json')
def collection_post(self):
result = self.request.json_body
print result
return True
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment