Python Cassandra cql: INSERT timestamp and blob
- or -
Post a project like this3326
$100
- Posted:
- Proposals: 3
- Remote
- #455079
- Awarded
Description
Experience Level: Intermediate
General information for the business: SaaS
Description of requirements/functionality: I am writing some python code that will collect data over time. I need to store this in Cassandra.
CREATE TABLE timearchive (name_yymmddhh text, name text, ip text, time_current timestamp, data blob, PRIMARY KEY (name_yymmddhh, time_current));
I can create the table, but I am having trouble inserting various data (time_current timestamp, data blob). I cannot format it correctly. I plan to have rows broken by hour (data size should be fine in my use case) and columns with each data entry (2-3/min).
Here is my code to insert. It works if I change the format of timestamp/blob to int/text.
query = """INSERT INTO """ + osarchivebulk + """
(name_yymmddhh, name, ip, time_current, data)
VALUES (:name_yymmddhh, :name, :ip, :time_current, :data)"""
values = {'name_yymmddhh':rowkey,
'name': dcname,
'ip': ip,
'time_current': timenow,
'data': my_blob}
cursor.execute(query, values)
Questions: Code example for each
1) How do I make a cql timestamp in python:
timenow = ???
2) My data is a dict. It will be a large dict of dicts and other data.
How do I put:
my_dict = {'one': 1, 'two': 2, 'three': 3}
...
my_blob = ???
OS requirements: Linux
Extra notes:
Description of requirements/functionality: I am writing some python code that will collect data over time. I need to store this in Cassandra.
CREATE TABLE timearchive (name_yymmddhh text, name text, ip text, time_current timestamp, data blob, PRIMARY KEY (name_yymmddhh, time_current));
I can create the table, but I am having trouble inserting various data (time_current timestamp, data blob). I cannot format it correctly. I plan to have rows broken by hour (data size should be fine in my use case) and columns with each data entry (2-3/min).
Here is my code to insert. It works if I change the format of timestamp/blob to int/text.
query = """INSERT INTO """ + osarchivebulk + """
(name_yymmddhh, name, ip, time_current, data)
VALUES (:name_yymmddhh, :name, :ip, :time_current, :data)"""
values = {'name_yymmddhh':rowkey,
'name': dcname,
'ip': ip,
'time_current': timenow,
'data': my_blob}
cursor.execute(query, values)
Questions: Code example for each
1) How do I make a cql timestamp in python:
timenow = ???
2) My data is a dict. It will be a large dict of dicts and other data.
How do I put:
my_dict = {'one': 1, 'two': 2, 'three': 3}
...
my_blob = ???
OS requirements: Linux
Extra notes:

Pete P.
100% (9)Projects Completed
12
Freelancers worked with
12
Projects awarded
65%
Last project
15 Sep 2014
United States
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies