Professional Web Applications Themes

Insert data in DB by using the script - MySQL

Hi, I have an sql script (generated by php) which contains only INSERT commands. The sql script should be launched everyday in order to insert data into the database. How can I accomplish the insetion (and connection to mysql DB before insertions) by using the Bourne shell script? Thanx in advance Don...

  1. #1

    Default Insert data in DB by using the script

    Hi,

    I have an sql script (generated by php) which contains only INSERT commands.

    The sql script should be launched everyday in order to insert data into
    the database.

    How can I accomplish the insetion (and connection to mysql DB before
    insertions) by using the Bourne shell script?

    Thanx in advance

    Don

    Don Guest

  2. #2

    Default Re: Insert data in DB by using the script

    Don wrote:
    > Hi,
    >
    > I have an sql script (generated by php) which contains only INSERT
    > commands.
    >
    > The sql script should be launched everyday in order to insert data into
    > the database.
    >
    > How can I accomplish the insetion (and connection to mysql DB before
    > insertions) by using the Bourne shell script?
    >
    > Thanx in advance
    >
    > Don
    >
    mysql -u[username] -p[password] [database] < input_file.sql

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    [email]jstucklexattglobal.net[/email]
    ==================
    Jerry Stuckle Guest

  3. #3

    Default Re: Insert data in DB by using the script

    Don wrote:
    > Hi,
    >
    > I have an sql script (generated by php) which contains only INSERT
    > commands.
    >
    > The sql script should be launched everyday in order to insert data into
    > the database.
    >
    > How can I accomplish the insetion (and connection to mysql DB before
    > insertions) by using the Bourne shell script?
    You can use the MySQL command line client :

    mysql -e "INSERT INTO db.adrbook (name, phone) VALUES ('Bob',
    '555-3211') "

    If your PHP generated file contains "clean" SQL commands,
    one per line, you can even use :

    mysql < myscript.sql


    --
    Robert
    Robert Larsson Guest

  4. #4

    Default Re: Insert data in DB by using the script

    "Don" <donvem-tech.com> wrote in message
    news:43f4996c$0$20164$8fcfb975news.wanadoo.fr...
    > The sql script should be launched everyday in order to insert data into
    > the database.
    You probably want to learn how to use cron. This is a tool that can run a
    command or script on a schedule. It is a common utility on every UNIX and
    Linux system, and available through cygwin tools on Windows.

    Your cron schedule can execute a shell script which invokes the 'mysql'
    command line tool in the manner described by Jerry and Robert, in their
    replies.

    Windows has a "Task Scheduler" service, but this appears to have been broken
    by a regression in Windows XP SP2. See
    [url]http://support.microsoft.com/default.aspx?scid=kb;en-us;884573[/url]

    Regards,
    Bill K.


    Bill Karwin Guest

  5. #5

    Default Re: Insert data in DB by using the script

    Hi Don,

    Just as an aside - if you want the insert to work quickly you should
    consider doing a multi row insert (one insert statement, multiple
    values). This will cause the indexes to be flushed once (at the end of
    the insert) instead of with every entry inserted...

    --
    Chander Ganesan
    Open Technology Group, Inc.
    Expert MySQL Training - at your site or ours
    [url]http://www.otg-nc.com/training-courses/category.php?cat_id=1[/url]

    Chander Ganesan Guest

Similar Threads

  1. Question Insert from ASP to SQL using recordset data as values in insert statement
    By JasonM in forum Microsoft SQL / MS SQL Server
    Replies: 0
    Last Post: June 13th, 05:54 PM
  2. Insert NULL not Blank into MySQL with PHP Script
    By Mark Davenport in forum PHP Development
    Replies: 3
    Last Post: June 3rd, 10:18 PM
  3. problem to insert script
    By drerolf in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 4
    Last Post: March 3rd, 05:15 PM
  4. Can't Insert Data
    By entoone in forum PHP Development
    Replies: 9
    Last Post: January 27th, 09:14 PM
  5. INSERT DATA
    By RAW in forum ASP.NET General
    Replies: 0
    Last Post: June 30th, 04:24 AM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139