SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    importing a text file to certain fields with Mysql

    I would like to import data from a text file to my database, but I want mysql to only update the record if it finds a match with one of the table fields or else it should add a new record to the table. Can I do this with mysql.
    Thanks

  2. #2
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The process that you describe will require a custom application or script written in a language that can interface with your mysql database. A language such as Python, PHP, Perl or Java would be ideal for creating such a program. What programming languages are you familiar with?

    - Marshall

  3. #3
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I work with Perl and some PHP.

  4. #4
    Are you ready for BSD? Marshall's Avatar
    Join Date
    Dec 2001
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is what your application needs to do:

    o Read in the text file line by line.
    o Use a SELECT statement based on values in that line to see if the record already exists in your database.
      If it exists, use UPDATE to modify it with the new values.
      If it doesn't exist, use INSERT to create the new record.

    If you need assistance with the coding, choose the language that you'd like to use and post a message to the appropriate language forum.

    G'Luck,
    - Marshall


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •