def abreRespositorio(self, accessMode=Repository.RENEW): """ Tests getting the repository up. Is called by the other examples to do the startup. """ print "Starting example1()." print "Default working directory is '%s'" % (CURRENT_DIRECTORY) server = AllegroGraphServer(AG_HOST, AG_PORT, AG_USER, AG_PASSWORD) print "Available catalogs", server.listCatalogs() ## catalog = server.openCatalog(AG_CATALOG) ## named catalog catalog = server.openCatalog() ## default rootCatalog print "Available repositories in catalog '%s': %s" % (catalog.getName(), catalog.listRepositories()) myRepository = catalog.getRepository(AG_REPOSITORY, accessMode) myRepository.initialize() conn = myRepository.getConnection() print "Repository %s is up! It contains %i statements." % ( myRepository.getDatabaseName(), conn.size()) indices = conn.listValidIndices() print "All valid triple indices: %s" % (indices) indices = conn.listIndices() print "Current triple indices: %s" % (indices) print "Removing graph indices..." conn.dropIndex("gospi") conn.dropIndex("gposi") conn.dropIndex("gspoi") indices = conn.listIndices() print "Current triple indices: %s" % (indices) print "Adding one graph index back in..." conn.addIndex("gspoi") indices = conn.listIndices() print "Current triple indices: %s" % (indices) return conn
def example0(): """ Can we connect to AG? """ print ("Starting example example0().") print "Current working directory is '%s'" % (os.getcwd()) server = AllegroGraphServer(AG_HOST, AG_PORT, AG_USER, AG_PASSWORD) print "Available catalogs", server.listCatalogs()
def connect_to_kabob(self): self.log.debug("Connecting to AllegroGraph server --" + "host:'%s' port:%s" % (KaBOB_Constants.HOST, KaBOB_Constants.PORT)) kabob_server = AllegroGraphServer(KaBOB_Constants.HOST, KaBOB_Constants.PORT, KaBOB_Constants.USER, KaBOB_Constants.PASSWORD) if KaBOB_Constants.CATALOG in kabob_server.listCatalogs( ) or KaBOB_Constants.CATALOG == '': kabob_catalog = kabob_server.openCatalog(KaBOB_Constants.CATALOG) if KaBOB_Constants.RELEASE in kabob_catalog.listRepositories(): mode = Repository.OPEN self.kabob_repository = kabob_catalog.getRepository( KaBOB_Constants.RELEASE, mode) self.kabob = self.kabob_repository.getConnection() # print('Repository %s is up!' % self.kabob_repository.getDatabaseName()) # print('It contains %d statement(s).' % self.kabob.size()) else: print('%s does not exist' % KaBOB_Constants.RELEASE) print("Available repositories in catalog '%s':" % kabob_catalog.getName()) for repo_name in kabob_catalog.listRepositories(): print(' - ' + repo_name) else: print('%s does not exist' % KaBOB_Constants.CATALOG) print('Available catalogs:') for cat_name in kabob_server.listCatalogs(): if cat_name is None: print(' - <root catalog>') else: print(' - ' + str(cat_name))
def getConnection(accessMode=Repository.ACCESS): print "getConnection" print "Default working directory is '%s'" % (CURRENT_DIRECTORY) server = AllegroGraphServer(AG_HOST, AG_PORT, AG_USER, AG_PASSWORD) print "Available catalogs", server.listCatalogs() catalog = server.openCatalog() print "Available repositories in catalog '%s': %s" % (catalog.getName(), catalog.listRepositories()) myRepository = catalog.getRepository(AG_REPOSITORY, accessMode) conn = myRepository.getConnection() print "Repository %s is up! It contains %i statements." % ( myRepository.getDatabaseName(), conn.size()) indices = conn.listValidIndices() print "All valid triple indices: %s" % (indices) indices = conn.listIndices() print "Current triple indices: %s" % (indices) return conn
print("mode: " + sys.argv[1]) file_path = "/INNUENDO/backups/" + sys.argv[2] print("file name:" + file_path) ################ CONNECTING TO ALLEGROGRAPH ############################ print("Connecting to AllegroGraph server --", "host:'%s' port:%s" % (AG_HOST, AG_PORT)) server = AllegroGraphServer(AG_HOST, AG_PORT, AG_USER, AG_PASSWORD) ################ SHOWING CATALOGS ###################################### print("Available catalogs:") for cat_name in server.listCatalogs(): if cat_name is None: print(' - <root catalog>') else: print(' - ' + str(cat_name)) ################ SHOWING REPOSITORIES ################################## catalog = server.openCatalog('') print("Available repositories in catalog '%s':" % catalog.getName()) for repo_name in catalog.listRepositories(): print(' - ' + repo_name) ################ CREATING REPOSITORY ################################### mode = Repository.ACCESS