コード例 #1
0
 def instantiateAbstractDb(self, dbName):
     """
     Instantiates an abstractDb.
     """
     if dbName not in list(self.dbDict.keys()):
         (host, port, user, password) = self.serverAbstractDb.getParamsFromConectedDb()
         abstractDb = DbFactory().createDbFactory(DsgEnums.DriverPostGIS)
         abstractDb.connectDatabaseWithParameters(host, port, dbName, user, password)
     else:
         abstractDb = self.dbDict[dbName]
     return abstractDb
コード例 #2
0
 def getDefaultPgDb(self, hostName):
     """
     Gets a standard PostGIS database object from a given host.
     :param hostName: (str) host name.
     :return: (AbstractDb) PostGIS database object.
     """
     abstractDb = DbFactory().createDbFactory(driver=DsgEnums.DriverPostGIS)
     (host, port, user,
      password) = abstractDb.getServerConfiguration(hostName)
     abstractDb.connectDatabaseWithParameters(host, port, 'postgres', user,
                                              password)
     return abstractDb
コード例 #3
0
 def instantiateAdminDb(self, serverAbstractDb):
     """
     Instantiates dsgtools_admindb in the same server as serverAbstractDb. 
     If dsgtools_admindb does not exists, instantiateAdminDb calls createAdminDb
     """
     (host, port, user, password) = serverAbstractDb.getParamsFromConectedDb()
     adminDb = DbFactory().createDbFactory(DsgEnums.DriverPostGIS)
     if not serverAbstractDb.hasAdminDb():
         return self.createAdminDb(serverAbstractDb, adminDb, host, port, user, password)
     adminDb.connectDatabaseWithParameters(host, port, 'dsgtools_admindb', user, password)
     managerType = self.getManagerType()
     if not adminDb.checkIfExistsConfigTable(managerType):
         adminDb.createPropertyTable(managerType, isAdminDb = True)
     return adminDb
コード例 #4
0
 def getAbstractDb(self, host, port, database, user, password):
     abstractDb = DbFactory().createDbFactory(DsgEnums.DriverPostGIS)
     abstractDb.connectDatabaseWithParameters(host, port, database, user,
                                              password)
     return abstractDb