473,809 Members | 2,791 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help with one line insert

I need to do a one line insert to a MySQL database from a Linux Shell.

I have a program that collects data and I can do a one-line shell call
after the data-update is finished. On this line I would like to send
the data from the program to a MySQL database.

The problem is that the program has all data in variables so I would
like to do something like this (postlog = after update):

postlog "insert var1, var2, var3 into database.table"

Can this be done in only one line shell call (program limit) or do I
have to write a script and pass variables?

If it can be done, how...

/Micke
Jul 20 '05 #1
2 1632
Micke wrote:
I have a program that collects data and I can do a one-line shell call
after the data-update is finished. On this line I would like to send
the data from the program to a MySQL database.


You can execute SQL statements from command-line arguments to the mysql
tool:

mysql -u $user -p$password $database -e "INSERT INTO myTable (field1,
field2, field3) VALUES ($var1, $var2, $var3)"

Regards,
Bill K.
Jul 20 '05 #2
A million thanks Bill. It works wounderful!!!

Regards,
/Micke

Bill Karwin <bi**@karwin.co m> wrote in message news:<cn******* **@enews4.newsg uy.com>...
Micke wrote:
I have a program that collects data and I can do a one-line shell call
after the data-update is finished. On this line I would like to send
the data from the program to a MySQL database.


You can execute SQL statements from command-line arguments to the mysql
tool:

mysql -u $user -p$password $database -e "INSERT INTO myTable (field1,
field2, field3) VALUES ($var1, $var2, $var3)"

Regards,
Bill K.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
7402
by: Jack | last post by:
I have a text file of data in a file (add2db.txt) where the entries are already entered on separate lines in the following form: INSERT INTO `reviews` VALUES("", "Tony's", "Lunch", "Great atmosphere. Good food.", " (Harry Houdini - 03/01/2004)"); INSERT INTO `reviews` VALUES("", "Le Chow Place", "Lunch", "yada yada", " (Herbert Hoover - 03/03/2004)"); INSERT INTO `reviews` VALUES("", "Golden Dragon", "Lunch", "Exquisite.
5
2726
by: Juho Saarikko | last post by:
I made a Python script which takes Usenet message bodies from a database, decodes uuencoded contents and inserts them as Large Object into a PostGreSQL database. However, it appears that the to last few bytes of uudecoded data are always mangled. Take a look of this hexdump output: Originals (decoded with Pan, each line is from a different file): 000c2c0 e1bf 00ff 2541 a9e4 a724 d9ff 0011a10 ff54 00d9 00093e0 fb4f a80d ffd9 c200 ffef...
3
4375
by: Jason Callas | last post by:
I have a stored procedure that runs as a step in a scheduled job. For some reason the job does not seem to finish when ran from the job but does fine when run from a window in SQL Query. I know the job is not working because the number of rows that are inserted into the table (see code) is considerably less than the manual runnning of it. I have included the code for the stored procedure, the output from the job, and the output from...
14
2976
by: Gregory L. Hansen | last post by:
I can't seem to make a queue of objects, using the STL queue. I'm trying to make a little event manager, and I just want someplace to store events. The method definitions for EventManager have been commented away to nothing during debugging, but the headers look like class Event { private: Object* recipient; int eventID;
3
4342
by: Steve | last post by:
i pulled an example off the web and modified it somewhat and whats killimg me is that sometimes it works and sometimes it doesnt. the following is the only line that allows this thing to work over and over, ive tried untold number of combinations , some have been left in as comments all will work right at the start but fail for no apparent reason later 'strsql = "insert into (orderinfofkey, lstring, link) values (1,'test', 'test2')" ...
4
2547
by: Takeadoe | last post by:
Dear NG - I've got a bunch of SQL statements (Insert Into "Access Table Name") generated from another software program. They look like this: Pasting these lines into the SQL view as they are generates a couple of different errors (missing semicolon being one of them). They work fine if I paste 1 line at a time. Can someone tell me what I need to do to remedy the situation? I can't hardly paste 1 at a time! Your help is very much...
8
5030
by: Red | last post by:
If auto-format is turned off in VS2008, there is apparently no way to indent a line. Under Tools->Options->Text Editor->C#->Formatting, there are three checkboxes. Unchecking those seems to cause this behavior. I'd simply like to have the tab key insert a tab at the beginning of a line. I believe that there were publlished macros for doing this in earlier VS versions, but I expected this to be 'fixed' in VS2008. Yes, I realize someone...
2
1087
by: xiuli | last post by:
I am trying to match two patterns in a file and insert a line. If the patterns matche then insert a line after the second matching pattern line. for example, I have the following content in a file: //This is my source file pin(name1) { clock;
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.