source: TI12-security/trunk/python/Tests/sqlalchemy/test_sqlalchemy.py @ 5037

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/TI12-security/trunk/python/Tests/sqlalchemy/test_sqlalchemy.py@5907
Revision 5037, 1.4 KB checked in by pjkersha, 11 years ago (diff)

ndg.security.server.wsgi.authn: AuthNMiddleware and AuthNRedirectMiddleware catch HTTP 401 responses from a WSGI application stack to be protected and redirect to OpenID Relying Party middleware running on an application server running NDG Security services.

  • Property svn:executable set to *
Line 
1#!/usr/bin/env python
2import getpass
3from sqlalchemy import create_engine
4
5from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
6
7class CreateResourceConstraintsDb(object):
8
9    def createResourceConstraintsTable(self):
10        metadata = MetaData()
11        users_table = Table('resource_constraints', metadata,
12            Column('id', Integer, primary_key=True),
13            Column('uri_regex', String))
14       
15    def createActionTypeTable(self):
16        metadata = MetaData()
17        users_table = Table('action_type', metadata,
18            Column('id', Integer, primary_key=True),
19            Column('uri_regex', String),
20            Column('action', String))
21       
22    def createAttributesTable(self):
23        metadata = MetaData()
24        users_table = Table('attributes', metadata,
25            Column('id', Integer, primary_key=True),
26            Column('uri_regex', String),
27            Column('attribute', String))
28           
29if __name__ == "__main__":
30    import sys
31    import pdb;pdb.set_trace()
32    username, hostname, dbName = sys.argv[1:]
33   
34    # postgres
35    pwd = getpass.getpass()
36    pg_db = create_engine('postgres://%s:%s@%s/%s' % 
37                          (username, pwd, hostname, dbName))
38    connection = pg_db.connect()
39    result = connection.execute("select * from users")
40    for row in result:
41        print ', '.join(["%s=%s" % (k,v) for k,v in row.items()])
42    connection.close()
43
44
Note: See TracBrowser for help on using the repository browser.