當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。