当前位置: 首页>>代码示例>>Python>>正文


Python cluster.Session方法代码示例

本文整理汇总了Python中cassandra.cluster.Session方法的典型用法代码示例。如果您正苦于以下问题:Python cluster.Session方法的具体用法?Python cluster.Session怎么用?Python cluster.Session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cassandra.cluster的用法示例。


在下文中一共展示了cluster.Session方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_cql_insert

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def create_cql_insert(self):
        """
        Given a table, prepares a statement to allow the dataframe to be inserted row by row into cassandra.

        Sets statement_input to be the prepared statement.

        :return: 0
        """
        assert isinstance(self.session, Session)
        assert self.table is not None

        statement = "INSERT INTO " + self.table + "(" + paste(self._cql_columns) + ") VALUES (" + paste(["?"] * len(self.columns)) + ");"



        self.statement_input   = self.session.prepare(statement)

        self._prepared_columns = self._cql_columns

        return 
开发者ID:aaronbenz,项目名称:caspanda,代码行数:22,代码来源:bamboo.py

示例2: set_session

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def set_session(self, session):
        """
        Setter method for self.session.

        Pass a session object or None.

        :return: None
        """
        if session is None:
            self.session = None

        else:
            assert isinstance(session, Session), "Got non-session, type: {}".format(type(session))
            self.session = session

        return 
开发者ID:aaronbenz,项目名称:caspanda,代码行数:18,代码来源:bamboo.py

示例3: __init__

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def __init__(self, session: Session, key_space: str, strategy: str, replications: int):
        self.session = session
        self.statements = dict()
        self.key_space = key_space
        self.key_space_test = key_space + 'test'
        self.strategy = strategy
        self.replications = replications
        self.logger = logging.getLogger(__name__) 
开发者ID:thenetcircle,项目名称:dino,代码行数:10,代码来源:cassandra_driver.py

示例4: get_conn

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def get_conn(self) -> Session:
        """
        Returns a cassandra Session object
        """
        if self.session and not self.session.is_shutdown:
            return self.session
        self.session = self.cluster.connect(self.keyspace)
        return self.session 
开发者ID:apache,项目名称:airflow,代码行数:10,代码来源:cassandra.py

示例5: __init__

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def __init__(self, hashes: Iterable, batch_size: int, session: Session, table: str):
        self.hashes = iter(hashes)
        self.batch_size = batch_size
        self.session = session
        self.table = table
        self.buffer = []
        self._log = logging.getLogger("BatchedHashResolver") 
开发者ID:src-d,项目名称:apollo,代码行数:9,代码来源:cassandra_utils.py

示例6: aiosession

# 需要导入模块: from cassandra import cluster [as 别名]
# 或者: from cassandra.cluster import Session [as 别名]
def aiosession(session, *, executor=None, loop=None):
    if not isinstance(session, Session):
        raise RuntimeError(
            'provide cassandra.cluster.Session')

    if hasattr(session, '_asyncio_fut_factory'):
        raise RuntimeError(
            'session is already patched by aiosession')

    if executor is not None:
        if not isinstance(executor, ThreadPoolExecutor):
            raise RuntimeError(
                'executor should be instance of ThreadPoolExecutor')

    if loop is None:
        loop = asyncio.get_event_loop()

    session._asyncio_loop = loop
    session._asyncio_executor = executor
    session._asyncio_fut_factory = _asyncio_fut_factory(loop=loop)

    session._asyncio_result = MethodType(_asyncio_result, session)
    session._asyncio_exception = MethodType(_asyncio_exception, session)
    session.execute_future = MethodType(execute_future, session)
    session.execute_futures = MethodType(execute_futures, session)
    session.prepare_future = MethodType(prepare_future, session)

    return session 
开发者ID:aio-libs,项目名称:aiocassandra,代码行数:30,代码来源:aiocassandra.py


注:本文中的cassandra.cluster.Session方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。