Ejemplo n.º 1
0
    def _connectorFor(self):
        kwargs = {
            "endpoint": "tcp:192.168.56.101:1521",
            "database": "orcl",
            "user": self.dsnUser if self.dsnUser else "hr",
            "password": "******",
        }

        return DBAPIConnector.connectorFor("oracle", **kwargs)
Ejemplo n.º 2
0
    def _connectorFor(self):
        kwargs = {
            "endpoint": "tcp:192.168.56.101:1521",
            "database": "orcl",
            "user": self.dsnUser if self.dsnUser else "hr",
            "password": "******",
        }

        return DBAPIConnector.connectorFor("oracle", **kwargs)
Ejemplo n.º 3
0
    def _connectorFor(self, databaseName=None):
        if databaseName is None:
            databaseName = self.databaseName

        kwargs = {"database": databaseName}

        if self.host.startswith("/"):
            kwargs["endpoint"] = "unix:{}".format(self.host)
        else:
            kwargs["endpoint"] = "tcp:{}".format(self.host)
            if self.port:
                kwargs["endpoint"] = "{}:{}".format(kwargs["endpoint"], self.port)
        if self.spawnedDBUser:
            kwargs["user"] = self.spawnedDBUser
        elif self.uid is not None:
            kwargs["user"] = pwd.getpwuid(self.uid).pw_name

        return DBAPIConnector.connectorFor("postgres", **kwargs)
Ejemplo n.º 4
0
    def _connectorFor(self, databaseName=None):
        if databaseName is None:
            databaseName = self.databaseName

        if self.spawnedDBUser:
            dsn = "{}:dbname={}:{}".format(self.host, databaseName,
                                           self.spawnedDBUser)
        elif self.uid is not None:
            dsn = "{}:dbname={}:{}".format(self.host, databaseName,
                                           pwd.getpwuid(self.uid).pw_name)
        else:
            dsn = "{}:dbname={}".format(self.host, databaseName)

        kwargs = {}
        if self.port:
            kwargs["host"] = "{}:{}".format(self.host, self.port)

        return DBAPIConnector(pgdb, postgresPreflight, dsn, **kwargs)
Ejemplo n.º 5
0
    def _connectorFor(self, databaseName=None):
        if databaseName is None:
            databaseName = self.databaseName

        kwargs = {
            "database": databaseName,
        }

        if self.host.startswith("/"):
            kwargs["endpoint"] = "unix:{}".format(self.host)
        else:
            kwargs["endpoint"] = "tcp:{}".format(self.host)
            if self.port:
                kwargs["endpoint"] = "{}:{}".format(kwargs["endpoint"],
                                                    self.port)
        if self.spawnedDBUser:
            kwargs["user"] = self.spawnedDBUser
        elif self.uid is not None:
            kwargs["user"] = pwd.getpwuid(self.uid).pw_name
        kwargs["txnTimeoutSeconds"] = self.txnTimeoutSeconds

        return DBAPIConnector.connectorFor("postgres", **kwargs)
Ejemplo n.º 6
0
def pgConnectorFromConfig(config):
    """
    Create a postgres DB-API connector from the given configuration.
    """
    import pgdb
    return DBAPIConnector(pgdb, postgresPreflight, config.DSN).connect