def view(self): '''Views allow OSIS users/developers/administrators to define their desired specific ways to query the stored objects.\ Every view needs to be updated on every store action. ''' print '\n\033[1;34mRegistering a View \n\033[1;32m[ ]osisdb = OsisDB()\n[ ]conn = osisdb.getConnection(\'main\')\n' print '\033[1;32m[ ]view = conn.viewCreate(\'company\', \'name\')\n[ ]view.setCol(\'name\', q.enumerators.OsisType.STRING, False)\n' print '[ ]view.setCol(\'url\', q.enumerators.OsisType.STRING, False)\n[ ]conn.viewAdd(view)' osisdb = OsisDB() try: conn = osisdb.getConnection('main') view = conn.viewCreate('company', 'name') view.setCol('name', q.enumerators.OsisType.STRING, False) view.setCol('url', q.enumerators.OsisType.STRING, False) conn.viewAdd(view) except Exception, e: print '\033[1;32mView Already Exists'
q.manage.postgresql8.applyConfig() ##if postgresql fails to start using the q.manage commands use #q.cmdtools.postgresql8.pg_ctl.start(username) print '\n\033[1;34mAdd Database:\n\033[1;32m[ ]q.manage.postgresql8.cmdb.addDatabase(\'osis\')\n' q.manage.postgresql8.cmdb.addDatabase('osis') #q.manage.postgresql8.cmdb.save() q.manage.postgresql8.applyConfig() print '\n\033[1;34mView the created Database:\n\033[1;32m[ ]q.manage.postgresql8.cmdb.printDatabases()\n' q.manage.postgresql8.cmdb.printDatabases() osisdb = OsisDB() print '\n\033[1;34mAdd Connection for the database:\n\033[1;32m[ ]osisdb.addConnection(\'main\', \'127.0.0.1\', \'osis\', \'qbase\', \'qbase\')' try: osisdb.addConnection('main', '127.0.0.1', 'osis', 'qbase', 'qbase') #Register Model on server print '\n\033[1;34mGet a connection for the database:\n\033[1;32m[ ]con = osisdb.getConnection(\'main\')\n' con = osisdb.getConnection('main') print '\n\033[1;34mCreate an object in the database:\n\033[1;32m[ ]con.createObjectTypeByName(\'company\') \n' print con.createObjectTypeByName('company') con.createObjectTypeByName('company') print '\n\033[1;34mInitialise OSIS System: \n\033[1;32m[ ]osis.init(\'/opt/qbase3/libexec/osis\') \n' print osis.init('/opt/qbase3/libexec/osis') except Exception, e: print 'Connection to OSIS Database Failed. Check if Model file is present' def store(self): '''This function is used to store data in the database. First a transport is obtained to establish a client connection, and then data is fed\ & saved in database''' print '\n\033[1;34mStores an object in the Database. \n\033[1;33m' try: transport = XMLRPCTransport('http://localhost:8888', 'osis_service')