Forum: Building VoltDB Applications

Post: Importing Data

Importing Data
Feb 9, 2010
Will there be a preferred way to import data, e.g. from a CSV file, or SQL, directly into the data base?

Importing Data
Feb 10, 2010

There are currently 2 options to load data into VoltDB, both would load data from the filesystem (the format is up to you: CSV, TSV, JSON, XML, etc.) and require you to write a simple file parser:

1. Create a simple stored procedure to insert into the proper table. You'll need to create a stored procedure for each of the tables you want to load into and call it for each row of data in your input file.

2. Use the @LoadMultipartitionTable system procedure, you can load multiple rows of data from your input file and call it similar to the following (this technique saves you from creating a stored procedure and makes it easy to load multiple rows in a single invocation):

VoltTable vtLoad = new VoltTable( new VoltTable.ColumnInfo(“ID”, VoltType.INTEGER), new VoltTable.ColumnInfo(“VAL”, VoltType.INTEGER));

Object row[] = new Object[2]; row[0] = 1; row[1] = 200; vtLoad.addRow(row);try { callProcedure(“@LoadMultipartitionTable”,“tab1”,vtLoad);} catch (Exception e) { e.printStackTrace();}