This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index 7abca4f..c451f90 100644 | |
--- a/pycassa/connection.py | |
+++ b/pycassa/connection.py | |
@@ -47,6 +47,7 @@ class ClientTransport(object): | |
"""Encapsulation of a client session.""" | |
def __init__(self, keyspace, server, framed_transport, timeout, credentials, recycle): | |
+ self.server = server | |
host, port = server.split(":") | |
socket = TSocket.TSocket(host, int(port)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DatetimeStingType(pycassa.types.CassandraType): | |
def __init__(self): | |
self.pack = lambda dtime: dtime.strftime('%Y-%m-%d') | |
self.unpack = lambda dtime_str: datetime.strptime('%Y-%m-%d') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[default@unknown] connect localhost/9160; | |
Connected to: "Test Cluster" on localhost/9160 | |
[default@unknown] create keyspace Foo; | |
b2461b50-838a-11e1-0000-242d50cf1ffe | |
Waiting for schema agreement... | |
... schemas agree across the cluster | |
[default@unknown] use Foo; | |
Authenticated to keyspace: Foo | |
[default@Foo] CREATE COLUMN FAMILY mycf | |
... WITH column_type = 'Standard' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time, logging | |
import pycassa | |
from pycassa.system_manager import SystemManager, SIMPLE_STRATEGY | |
pycassa.PycassaLogger().get_logger().addHandler(logging.StreamHandler()) | |
sys = SystemManager() | |
if "Keyspace1" not in sys.list_keyspaces(): | |
sys.create_keyspace("Keyspace1", SIMPLE_STRATEGY, {"replication_factor": "1"}) | |
sys.create_column_family("Keyspace1", "CF1", super=True) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE scores ( | |
some_partition_key text, | |
score int, | |
test_id uuid, | |
field_a text, | |
field_b text, | |
PRIMARY KEY (some_partition_key, score, test_id) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$cf->return_format = ColumnFamily::ARRAY_FORMAT; | |
function get_page($cf, $key, $page, $page_size) { | |
$start_col = ""; | |
$current_page = 0; | |
$page_data = null; | |
while ($current_page < $page) { | |
// fetch one extra column at the end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/pycassa (master)$ ./pycassaShell -k Keyspace1 | |
---------------------------------- | |
Cassandra Interactive Python Shell | |
---------------------------------- | |
Keyspace: Keyspace1 | |
Host: localhost:9160 | |
Available ColumnFamily instances: | |
* CF1 ( CF1 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require_once(__DIR__.'/lib/autoload.php'); | |
use phpcassa\Connection\ConnectionPool; | |
use phpcassa\ColumnFamily; | |
use phpcassa\Index\IndexExpression; | |
use phpcassa\Index\IndexClause; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cqlsh> CREATE KEYSPACE keyspace1 WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1' }; | |
cqlsh> use keyspace1; | |
cqlsh:keyspace1> CREATE TABLE cf3 ( key blob PRIMARY KEY, id varint, postcode text, price varint ) WITH COMPACT STORAGE; | |
cqlsh:keyspace1> CREATE INDEX cf3_id_idx ON cf3 (id) ; | |
cqlsh:keyspace1> CREATE INDEX cf3_price_idx ON cf3 (price) ; | |
cqlsh:keyspace1> DESCRIBE COLUMNFAMILY keyspace1.cf3; | |
CREATE TABLE cf3 ( | |
key blob PRIMARY KEY, | |
id varint, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cqlsh:keyspace1> UPDATE mentions SET mentions = 3 WHERE day = '01/05/11' AND item = 'acunu' AND time = 1; | |
cqlsh:keyspace1> select * from mentions; | |
day | item | time | mentions | |
----------+-------+------+---------- | |
01/05/11 | acunu | 1 | 3 | |
cqlsh:keyspace1> UPDATE mentions SET mentions = 5 WHERE day = '01/05/11' AND item = 'acunu' AND time = 2; | |
cqlsh:keyspace1> select * from mentions; |
OlderNewer