# Ruby SDK Data Import This article describes how to import the data from your Ruby applications using Treasure Data’s Ruby SDK. ### Prerequisites - Basic knowledge of Ruby, Gems, and Bundler. - Basic knowledge of Treasure Data. - Ruby 3.4 or higher (for local testing). ### Install `td` Gem Add the `td` (Treasure Data) gem to your `Gemfile`. ``` gem 'td', "~> 3.0.0" ``` Install the gem locally via bundler. ```bash bundle install ``` ### Modify Your App The `td` gem comes with a built-in library for recording in-app events. Insert code, as shown in the following example, to record events from your app. Further details regarding the event logger API can be found in the GitHub repository [td-logger-ruby](https://github.com/treasure-data/td-logger-ruby). `YOUR_API_KEY` should be your actual apikey string. `YOUR_API_KEY` should be your actual apikey string. You can retrieve your API key from your profiles in TD Console. Using a [write-only API key](/products/my-settings/getting-your-api-keys) is recommended. ```ruby # Initialization TreasureData::Logger.open('production', :apikey=>"YOUR_API_KEY", :auto_create_table=>true) # Example1: login event TD.event.post('login', {:uid=>123}) # Example2: follow event TD.event.post('follow', {:uid=>123, :from=>'TreasureData', :to=>'kzk_mover'}) # Example3: pay event TD.event.post('pay', {:uid=>123, :item_name=>'Stone of Jordan', :category=>'ring', :price=>100, :count=>1}) ``` Your event-logging code should be placed near its corresponding event-generating code. When using the `td` gem, the posted records are buffered in the memory locally at first, and the data is uploaded every 5 minutes. Because a dedicated thread uploads the data into the cloud, it doesn’t affect your application’s response time. The local buffer also has a size limit. If the local data exceeds this limit, the records are uploaded immediately. ### Confirming Data Import The data gets uploaded every 5 minutes. You can confirm the data import from TD Console or CLI. **From TD Console** To confirm that your data has been uploaded successfully, check your dataset from the TD Console. **From CLI** Issue the `td tables` command if you have the [TD Toolbelt](https://docs.treasuredata.com/tools/cli-and-sdks/td-toolbelt) CLI. ```bash td tables ``` ```bash +------------+------------+------+-----------+ | Database | Table | Type | Count | +------------+------------+------+-----------+ | production | login | log | 1 | | production | follow | log | 1 | | production | pay | log | 1 | +------------+------------+------+-----------+ ```