Cassandra not value inserted - cassandra-0.7

I'm using cassandra.my columnfamily is testcassa and the column is test1. I tried to insert value like set testcassa['123'][test1]='Sample' but it returns 'null'. and no error message.. can anyone help me..
thanks in advance.

[default#unknown] create keyspace mykeyspace;
[default#unknown] use mykeyspace;
[default#mykeyspace] set cf1[1]['c2']=utf8('test');
[default#mykeyspace] get cf1[1];
[default#mykeyspace] set cf1[1]['c2']=utf8('test2');
[default#mykeyspace] del cf1[1];

Related

Array stored as String - How to extract pieces of it?

I got a problem with a specific database where some tags from a user profile are stored as a String data type, and so far I have not figured out how to fetch data from this one.
Example String:
{"watch_intro": "Gifts from my family.", "favorite_brands_styles": ["Fossil","Tudor","Omega"]}
I am looking to query into this field and get something like below:
'Fossil, Tudor, Omega'
Any help would be appreciated, thanks.
Nevermind, found the answer:
array_to_string(PARSE_JSON(EXTRA_INFO):"favorite_brands_styles",', ') AS fav_brands

Setting Multiple Variables in SQL in one Query?

I have the following line of code.
UPDATE account
SET BlockMessage='$BlockMessage', SET BlockAdmin='$AdminUsername', Status=2
WHERE ID='$ID'
As you can see in trying to set a "BlockMessage, BlockAdmin and Status" in 1 single query. The Infomation is correctly displayed if I echo the 3 individual Variables. however, when running the SQL String it only updates the Block Message row.
Any Ideas?
You have an extra SET. Update should be something like this:
UPDATE account
SET
BlockMessage='$BlockMessage',
BlockAdmin='$AdminUsername',
Status=2
WHERE ID='$ID'
You need use the keyword SET only once like
SET BlockMessage='$BlockMessage',
BlockAdmin='$AdminUsername',
Status=2

How to use update from select in postgreSQL?

update users
set users.przetwarzanie = historia_panel.zmiana_z
from historia_panel
where
users.user_number like historia_panel.user_number and
historia_panel.zmienna_zmieniana like '%przetwarzanie%' and
historia_panel.przyczyna like '%użytkownika%';
And the error is:
The error that is in console:
ERROR: column "users" of relation "users" does not exist
LINE 2: set users.przetwarzanie = historia_panel.zmiana_z
In this query i want to update users table with values from historia_panel table with specified conditions. I tried many different ways but none of examples that i found on the internet works.
Actualy i have no idea what I'am doing wrong...
The error would suggest that you aren't allowed to qualify the column names in the set clause; and indeed you shouldn't need to since you already said update users
Whether that's the only problem I can't say at a quick glance, but that is what the error message is telling you; so try changing set users.przetwarzanie = historia_panel.zmiana_z to just set przetwarzanie = historia_panel.zmiana_z and see what you get
The problem was with incompatible typles between two columns from different tables. I added line set przetwarzanie = historia_panel.zmiana_z::int and now it works.

UPDATE datatype image in SQL-Table

I've a table cSc_Role with a column RoleSettings.
RoleSettings is datatype image.
The Content is something like this: 0x504B030414000000080000000000E637CA2A4
Now I need to update this column for one row.
Like this:
UPDATE cSc_Role
SET RoleSettings = '0x343240000000000E637CA2A430500'
WHERE Naming = 'User X'
But with binary data it seems like this is not possible to do it with a string.
The other option is, I can provide the image in a temporary .bak file.
And then do an INSERT INTO.
But with this solution I've read it is only possible to insert a complete row and not only a column. Or can I insert only a column with insert?
How can I update or insert one image-column in a table?
Thanks in advance.
Try to use convert to varbinary:
UPDATE cSc_Role
SET RoleSettings = convert(VARBINARY(MAX),'0x343240000000000E637CA2A430500')
WHERE Naming = 'User X'
If above all solution did not work then try to update like below by removing '' in following ,
UPDATE cSc_Role
SET RoleSettings = 0x343240000000000E637CA2A430500
WHERE Naming = 'User X'
Also, avoid using these data types (ntext, text, and image) in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead.
Use a hex-literal, x'34....'
UPDATE cSc_Role
SET RoleSettings = x'343240000000000E637CA2A430500'
WHERE Naming = 'User X'
I had a same problem on project, you need to provide binary data as hex value, not string. This tool can make you UPDATE or INSERT that you need
Binary-file-to-sql-hexstring
It has saved me a lot of man hours.

web.py db.insert() doesn't work

I use db.insert() to insert data to database, the code is something like this,
db.insert('categories', name=cate_name, description=desc, _test=True)
but it doesn't work, the data can't not be found in table 'categories' after the code is execute, and no exceptions by the way.
Anybody know why this happened?
_Test variable stands for debug purposes.
It lets you get SQL statement instead of executing one.
It means that your command
result = db.insert('categories', name=cate_name, description=desc, _test=True)
will not execute anything on your DB. It will only return a string:
"INSERT INTO categories (name, description) VALUES ('cate_name value', 'desc value')"
If you want to make a real query, you need to remove it:
db.insert('categories', name=cate_name, description=desc)
It should work.
remove _test=True or set _test=False