cql - Cassandra Query Language Interface
Cassandra Query Language interface.
- cassy.cql.create_keyspace(keyspace, session, replication='simple')[source]
Create keyspace via session if neccessary.
- cassy.cql.get_cluster_name(session)[source]
Querry session for current cluster name.
- Parameters
session¶ (cassandra.cluster.Session) – cassandra.session.Session Used to query the cluster for its name.
- Returns
Name of the cassandra cluster, the current session is connected to.
- Return type
- cassy.cql.list_column_values(cluster, session, keyspace, table, column)[source]
List all column values of table in keyspace.
- Parameters
cluster¶ (cassandra.cluster.Cluster) – cassandra.cluster.Cluster object holding the cassandra database.
session¶ (cassandra.cluster.Session, default=None) –
cassandra.session.Session used to query the table for clumn values.
keyspace¶ (str) – String specifying the keyspace of the
clusterwheretableis to be found.table¶ (str) – String specifying the table inside the
keyspaceofclusterof which the column labels are to be listed.column¶ (Number, str) – Column specifier of which the values are to be listed.
- Returns
List of strings specifying the found column values
- Return type
- Raises
KeyError – Key Error raised if
keyspace,tableorcolumnare unsuccesfully white-listed.
- cassy.cql.get_all_entries(cluster, session, keyspace, table)[source]
Get all rows of a table.
- Parameters
cluster¶ (cassandra.cluster.Cluster) –
cassandra.cluster.Cluster object holding the cassandra database.
session¶ (cassandra.cluster.Session) –
cassandra.session.Session Use to execute query statement.
keyspace¶ (str) – String specifying the default keyspace the
tableis found.
- Returns
List of dictionairies of found entries.
- Return type
- Raises
KeyError – Key Error raised if
keyspaceortableare unsuccesfully white-listed.
- cassy.cql.drop_row(cns, keyspace, table, primary_key, value)[source]
Drop(delete) a cassandra table row.
- Parameters
cns¶ (NamedTuple) –
Tuple of cassandra.session.Cluster and cassandra.session.Session as in
('cluster'=cluster, 'session'=session)and returned bycassy.casdriv.connect_session().keyspace¶ (str) – String specifying the default keyspace the
tableis found.table¶ (str) – String specifying the table of which to drop a row.
primary_key¶ (str) – String specifying/identifying the primary key of the row to be dropped.
value¶ –
primary_keyvalue of the row to be dropped.
- Raises
KeyError – Key Error raised if
keyspace,table,primary_key,valueare unsuccesfully white-listed.
Examples
Dropping a row from the Martin Crawford database assuming a cluster and session were created using
cassy.casdriv.connect_session():drop_row( cns=(cluster, session), keyspace="crawford", table="common_fruiting_trees", primary_key="latin", value="Prunus domestica", )
- cassy.cql.drop_all_rows(cluster, session, keyspace, table)[source]
Drop(delete) an entire tables rows/content.
- Parameters
cluster¶ (cassandra.cluster.Cluster) –
cassandra.cluster.Cluster object holding the cassandra database.
session¶ (cassandra.cluster.Session) –
cassandra.session.Session Use to execute query statement.
keyspace¶ (str) – String specifying the default keyspace the
tableis found.table¶ (str) – String specifying the table of which to drop all rows.
- Raises
KeyError – Key Error raised if
keyspaceortableare unsuccesfully white-listed.