![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Inserting records from flat file to db table | Hara | Shell Programming and Scripting | 4 | 12-27-2006 12:35 AM |
| inserting into a data file | paul1s | UNIX for Dummies Questions & Answers | 4 | 10-12-2006 11:47 PM |
| Inserting Values From A File Into A Table | ragha81 | Shell Programming and Scripting | 2 | 09-16-2006 04:10 PM |
| Editing a mySQL table on a remote machine | Sn33R | UNIX for Dummies Questions & Answers | 6 | 10-13-2003 10:47 PM |
| MySql: create table error | perleo | Shell Programming and Scripting | 3 | 04-16-2003 02:23 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Help Inserting data in mysql table
Cant understand the error
#!/bin/bash temp="" A="" D=$(date +"%Y-%m-%d") H=$(date +"%R") temp=$(wget -q -O - website | grep -o "Temperature:[[:space:]]*[0-9][0-9]*" | grep \-E -o "[0-9]+") mysql -D "weather_wise" -e "INSERT INTO weather (Date, Hour, Degrees) VALUES ($D,$H, $temp)"; my data types for Date an Hour are both date Im getting error below i think on $D and $H......Please help me where am i going wrong ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':39, 7)' at line 1 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
The type DATE evaluates to only 'YYYY-MM-DD' when you try to insert your time stamp, it will be of the form 'HH:MM'
If you were to change the "Hour" portion of your able to be of type TIME you wouldn't have any trouble inserting your 'HH:MM' into your table. |
|
#3
|
|||
|
|||
|
I'm not familiar with myslq but perhaps you must convert the date and time with makedate() and maketime() before you can inserting them.
Regards |
|
#4
|
|||
|
|||
|
i have tried that but same error though
|
|
#5
|
|||
|
|||
|
I found this page with a explanation how to insert dates in mysql, hope this helps:
MySQL Tutorial - Date Regards |
|
#6
|
||||
|
||||
|
You need to add the values in quotes
Code:
mysql -D "weather_wise" -e "INSERT INTO weather (Date, Hour, Degrees) VALUES ('$D','$H', '$temp')";
|
|
#7
|
|||
|
|||
|
Quote:
would you know how to limit time to only hour and minute? |
|||
| Google The UNIX and Linux Forums |