def _from_connection(conn): ds = datasource(None) ds._conn = conn ds._update_cursor = ds._conn.cursor() return ds
def _from_params(kw): if kw.has_key("db"): kw["database"] = kw["db"] del kw["db"] self = datasource(**kw) if kw.has_key("charset"): encoding = kw["charset"] self._backend_encoding = self.encodings.get(encoding, "ascii") else: self._backend_encoding = "iso-8859-1" # probably the most common return self
def _from_params(params): """ A pgsql connection string may contain all the standard ORM keywords plus all of those described above in the __init__ method's doc """ if params.has_key("db"): dbname = params["db"] del params["db"] params["dbname"] = dbname dsn = [] for a in params.items(): dsn.append("%s=%s" % a) return datasource(join(dsn, " "))
def _from_params(params): """ Construct a mysql datasource object from an orm connection string. A connection string for the mysql adapter may contain all keywords defined in orm2.datasource plus all those that are described as keyword parameters for __init__ above. """ if params.has_key("password"): passwd = params["password"] del params["password"] params["passwd"] = passwd if params.has_key("dbname"): dbname = params["dbname"] del params["dbname"] params["db"] = dbname return datasource(**params)
def _from_params(params): database_name = params.get("dbname", "tmp") database_directory = params.get("directory", "/tmp") encoding = params.get("encoding", "iso-8859-1") return datasource(database_name, database_directory, encoding)