Database Reference
In-Depth Information
Legacy applications built using traditional RDBMS and looking to NoSQL databases
for scalability and performance may require migrating data from RDBMS to Cas-
sandra. For example, financial applications want to migrate transaction logs, popular
websites storing activity logs in RDBMS, and now want to migrate the same to Cas-
sandra.
In the Traditional Way
This is the simplest possible way to export data from an RDBMS such as MySQL in a
CSV-format file and load the data in Cassandra. Let's discuss this more with a sample
exercise.
1.
First, let's create a database and table in MySQL:
create schema twitter;
create table twitterdata(id varchar(20)
primary key,screen_name varchar(20),body
varchar(30));
2.
Insert some sample tweets:
insert into twitterdata('1','mevivs','my
first tweet');
insert into twitterdata
values('2','jhassel','my first tweet');
insert into twitterdata
values('3','rfernando','my first tweet');
3.
Let's export data from the twitterdata table:
select * from twitterdata INTO OUTFILE '/tmp/
mysql_output.csv' Fields TERMINATED BY ','
ENCLOSED BY '"' LINES TERMINATED BY '\n';
4.
Next, let's create a table and keyspace in Cassandra:
create table ntwitterdata(id text primary
key, screen_name text, bodt text);
Search WWH ::




Custom Search