Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8277181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:36:45+00:00 2026-06-08T08:36:45+00:00

I’m trying to load different data, from different files, into multiple columns in MySQL.

  • 0

I’m trying to load different data, from different files, into multiple columns in MySQL. I’m not a big database guy, so maybe I have my data structured wrong. 🙂

Here’s how I have it set up:

DATABASE: mydb
TABLE:    aixserver1
COLUMNS:  os, hostname, num_users, num_groups, pkg_epoch

shown from mysql:

+---------------+-----------+------+-----+-------------------+----------------+
| Field         | Type      | Null | Key | Default           | Extra          |
+---------------+-----------+------+-----+-------------------+----------------+
| id            | int(11)   | NO   | PRI | NULL              | auto_increment |
| cur_timestamp | timestamp | NO   |     | CURRENT_TIMESTAMP |                |
| pkg_epoch     | int(11)   | NO   |     | NULL              |                |
| os            | char(5)   | YES  |     | NULL              |                |
| hostname      | char(40)  | YES  |     | NULL              |                |
| num_users     | int(10)   | YES  |     | NULL              |                |
| num_groups    | int(10)   | YES  |     | NULL              |                |
+---------------+-----------+------+-----+-------------------+----------------+

So basically I want to populate pkg_epoch, os, hostname, num_users and num_groups into the database. The data I want to load is inside 5 flat files on the server. I’m using ruby to load the data.

My question is how do I load all these values from those files into my table at once. If I do my inserts one at a time, then the other records become NULL. I.E, I load data into just the hostname column, and all the other columns become NULL for that row.

What am I missing? 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:36:47+00:00Added an answer on June 8, 2026 at 8:36 am

    You can do this a couple ways but the trick is to use a variable placeholder. Here is an example if you used the database’s LOAD DATA function:

    LOAD DATA INFILE '/PATH/TO/FILE' IGNORE INTO TABLE tableName FIELDS TERMINATED BY '\t' LINES  
    TERMINATED BY '\r' (@skip, @skip, @skip, login_name, pwd, @skip, @skip, @skip, @skip, @skip, first_name, last_name);
    

    You see I just set a variable @skip or @anything for the fields I don’t want to include in the database and name the columns that I do want.


    I can get you halfway there with this but am uncertain best approach if you build your own loader with Ruby. I would suggest you retrieve the file and let MySQL import using LOAD DATA as it’ll be very performant and you can use trick above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.