Bulk export
This page documents bulk export for YugabyteDB’s . To export data from a YugabyteDB (or even an Apache Cassandra) table, you can use the tool.
We will first create a source YugabyteDB table and populate it with data. Then we will export the data out using the cassandra-unloader tool. We will use a generic gaming user profile use case as a running example to illustrate the export process.
# sample usage:
# To generate a 10GB (10240 MB) file.
# % python gen_csv.py <outfile_name> <outfile_size_MB>
# % python gen_csv.py file01.csv 10240
#
import numpy as np
import uuid
import csv
import sys
outfile = sys.argv[1] # output file name
outsize_mb = int(sys.argv[2])
print("Outfile = " + outfile)
print("Outfile Size (MB) = " + str(outsize_mb))
chunksize = 10000
while (os.path.getsize(outfile)//1024**2) < outsize_mb:
data = [[uuid.uuid4() for i in range(chunksize)],
np.random.random(chunksize)*1000,
np.random.random(chunksize)*50,
np.random.randint(1000000, size=(chunksize,)),
[uuid.uuid4() for i in range(chunksize)]]
csvfile.writelines(['%s,%.6f,%.6f,%i,%s\n' % row for row in zip(*data)])
Sample rows generated by script would like the following.
$ head file00.csv
To generate 5 CSV files of about 5 GB each, run the following commands.
python ./gen_csv.py file00.csv 5120 &
python ./gen_csv.py file01.csv 5120 &
python ./gen_csv.py file03.csv 5120 &
python ./gen_csv.py file04.csv 5120 &
You can do this as shown below.
$ wget https://github.com/yugabyte/cassandra-loader/releases/download/v0.0.27-yb-2/cassandra-loader
The files can be queued up for upload one at a time. Sample invocation:
-schema "load.users(user_id, score1, score2, points, object_id)" \
-boolStyle 1_0 \
-numFutures 1000 \
-rate 10000 \
-queryTimeout 65 \
-numRetries 10 \
-progressRate 200000 \
-host <clusterNodeIP> \
-f file01.csv
$ wget https://github.com/brianmhess/cassandra-loader/releases/download/v0.0.27/cassandra-unloader
./cassandra-unloader \
-schema "load.users(user_id, score1, score2, points, object_id)" \
-boolStyle 1_0 \
-f outfile.csv
For additional options to cassandra-unloader, see .