Python cassandra.cluster.Session() Examples
The following are 6
code examples of cassandra.cluster.Session().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
cassandra.cluster
, or try the search function
.
Example #1
Source File: bamboo.py From caspanda with MIT License | 7 votes |
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
Example #2
Source File: bamboo.py From caspanda with MIT License | 6 votes |
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
Example #3
Source File: cassandra_driver.py From dino with Apache License 2.0 | 5 votes |
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__)
Example #4
Source File: cassandra.py From airflow with Apache License 2.0 | 5 votes |
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
Example #5
Source File: cassandra_utils.py From apollo with GNU General Public License v3.0 | 5 votes |
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")
Example #6
Source File: aiocassandra.py From aiocassandra with MIT License | 5 votes |
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