def __init__(self, engine, **kw): super(RedisStore, self).__init__(engine, **kw) spliturl = urlsplit(engine) self._db = spliturl.path.replace('/', '') self._hostname = spliturl.hostname self._port = spliturl.port self._store = redis.Redis(spliturl.hostname, spliturl.port, self._db)
def __init__(self, engine, **kw): super(HStore, self).__init__(engine, **kw) spliturl = urlsplit(engine) try: self._conn = conn = psycopg2.connect( host=spliturl.hostname, port=spliturl.port, database=spliturl.path, user=spliturl.username or "", password=spliturl.password or "", ) self._store = db = conn.cursor(cursor_factory=extras.RealDictCursor) except psycopg2.OperationalError: logging.exception("configuration error") raise TypeError("configuration error") try: db.execute("CREATE EXTENSION hstore") conn.commit() except psycopg2.ProgrammingError: conn.rollback() extras.register_hstore(conn) try: db.execute("CREATE TABLE shove (id serial PRIMARY KEY, data hstore)") conn.commit() db.execute("INSERT INTO shove (data) VALUES (%s)", ['"key"=>"value"']) conn.commit() db.execute("UPDATE shove SET data = delete(data, %s)", ["key"]) except psycopg2.ProgrammingError: conn.rollback()
def __init__(self, engine, **kw): super(CassandraStore, self).__init__(engine, **kw) spliturl = urlsplit(engine) _, keyspace, column_family = spliturl.path.split('/') try: self._store = pycassa.ColumnFamily( pycassa.ConnectionPool(keyspace, [spliturl.hostname]), column_family, ) except pycassa.InvalidRequestException: from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8 system_manager = SystemManager(spliturl[1]) system_manager.create_keyspace( keyspace, pycassa.system_manager.SIMPLE_STRATEGY, dict(replication_factor=native(kw.get('replication', 1))), ) system_manager.create_column_family(keyspace, column_family) self._store = pycassa.ColumnFamily( pycassa.ConnectionPool(keyspace, [spliturl.netloc]), column_family, ) except pycassa.NotFoundException: from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8 system_manager = SystemManager(spliturl[1]) system_manager.create_column_family(keyspace, column_family) self._store = pycassa.ColumnFamily( pycassa.ConnectionPool(keyspace, [spliturl.netloc]), column_family, )
def __init__(self, engine, **kw): super(RedisCache, self).__init__(engine, **kw) spliturl = urlsplit(engine) host, port = spliturl[1].split(":") db = spliturl[2].replace("/", "") self._store = redis.Redis(host, int(port), db) # Set timeout self.timeout = kw.get("timeout", 300)
def __init__(self, engine, **kw): super(MongoDBStore, self).__init__(engine, **kw) spliturl = urlsplit(engine) _, dbpath, self._colpath = spliturl.path.split('/') self._conn = Connection(host=spliturl.hostname, port=spliturl.port) self._db = getattr(self._conn, dbpath) self._store = getattr(self._db, self._colpath) self._store.ensure_index('key', unique=True)
def __init__(self, engine, **kw): super(RedisCache, self).__init__(engine, **kw) spliturl = urlsplit(engine) host, port = spliturl[1].split(':') db = spliturl[2].replace('/', '') self._store = redis.Redis(host, int(port), db) # Set timeout self.timeout = kw.get('timeout', 300)
def __init__(self, engine, **kw): super(FTPStore, self).__init__(engine, **kw) user = kw.get('user', 'anonymous') password = kw.get('password', '') spliturl = urlsplit(engine) # Set URL, path, and strip 'ftp://' off base, path = spliturl[1], spliturl[2] + '/' if '@' in base: auth, base = base.split('@') user, password = auth.split(':') self._store = FTP(base, user, password) # Change to remote path if it exits try: self._store.cwd(path) except error_perm: self._makedir(path) self._base, self._user, self._password = base, user, password self._updated, self ._keys = True, None
def __init__(self, engine, **kw): super(FTPStore, self).__init__(engine, **kw) user = kw.get('user', 'anonymous') password = kw.get('password', '') spliturl = urlsplit(engine) # Set URL, path, and strip 'ftp://' off base, path = spliturl[1], spliturl[2] + '/' if '@' in base: auth, base = base.split('@') user, password = auth.split(':') self._store = FTP(base, user, password) # Change to remote path if it exits try: self._store.cwd(path) except error_perm: self._makedir(path) self._base, self._user, self._password = base, user, password self._updated, self._keys = True, None
def __init__(self, engine, **kw): super(CassandraStore, self).__init__(engine, **kw) spliturl = urlsplit(engine) _, keyspace, column_family = spliturl.path.split('/') try: self._store = pycassa.ColumnFamily( pycassa.ConnectionPool(keyspace, [spliturl.hostname]), column_family, ) except pycassa.InvalidRequestException: from pycassa.system_manager import SystemManager # @UnresolvedImport @IgnorePep8 system_manager = SystemManager(spliturl[1]) system_manager.create_keyspace( keyspace, pycassa.system_manager.SIMPLE_STRATEGY, dict(replication_factor=native(kw.get('replication', 1))), ) system_manager.create_column_family(keyspace, column_family) self._store = pycassa.ColumnFamily( pycassa.ConnectionPool(keyspace, [spliturl.netloc]), column_family, )