Sponsored Content
Full Discussion: Data comparison
Top Forums Shell Programming and Scripting Data comparison Post 302844883 by leghorn on Tuesday 20th of August 2013 08:29:07 AM
Old 08-20-2013
Data comparison

Hi

I have a linux server with mysql installed.There is some data in mysql tables.
Also.I have a .csv file (not from the aforementioned database)
I need to compare the data in the database nad the .csv and print out the difference.

I tried writing a shell script for that but I was unsuccessful.

I need to ask if there's any way I can export the data from mysql tables to .csv file format and use the diff command to see the comparison of the generated file and the file I had initially.

~thanks

---------- Post updated at 05:59 PM ---------- Previous update was at 05:56 PM ----------

I found one ..
Code:
mysql -uexampleuser -pletmein exampledb -B -e "select * from \`person\`;" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv

but before select statement could begin,I need to write another statement
use xyz;

how do I induce this (use xyzSmilie in the shell code .. piping isnt helping

~thanks

Last edited by Franklin52; 08-20-2013 at 09:32 AM.. Reason: Please use code tags
 

10 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

comparison

can anyone point me to a comparison of *nix file systems ? i think i prefer a journalling fs but i would like to see a comparison between several fs's before i make up my mind (2 Replies)
Discussion started by: cnf
2 Replies

2. Shell Programming and Scripting

need some help..Comparison

I need some help which would probably be for most of you a simple script. I need to read in the data from a .dat file and then compare avg to see who is the highest avg. Here is my script so far. #!/bin/ksh #reading in the data from lab3.dat filename=$1 while read name o1 o2 o3 o4 o5 o6... (0 Replies)
Discussion started by: bluesilo
0 Replies

3. UNIX for Dummies Questions & Answers

string comparison

Hi Guys i need to write a script to check the file structure I have added the the file headers in the configuration file and execute the file at the start of the script. Now the function checkFileStructure() { echo "Inside the function" filetocheck=$1 fileheader=$2 if ] then... (1 Reply)
Discussion started by: Swapna173
1 Replies

4. Shell Programming and Scripting

Extract data based on match against one column data from a long list data

My input file: data_5 Ali 422 2.00E-45 102/253 140/253 24 data_3 Abu 202 60.00E-45 12/23 140/23 28 data_1 Ahmad 256 7.00E-45 120/235 140/235 22 data_4 Aman 365 8.00E-45 15/65 140/65 20 data_10 Jones 869 9.00E-45 65/253 140/253 18... (12 Replies)
Discussion started by: patrick87
12 Replies

5. Shell Programming and Scripting

$((...)) and $[...] comparison

Does $((mathematical expression)) and $ mean the same? (7 Replies)
Discussion started by: proactiveaditya
7 Replies

6. Shell Programming and Scripting

Three Difference File Huge Data Comparison Problem.

I got three different file: Part of File 1 ARTPHDFGAA . . Part of File 2 ARTGHHYESA . . Part of File 3 ARTPOLYWEA . . (4 Replies)
Discussion started by: patrick87
4 Replies

7. Shell Programming and Scripting

row Comparison

(5 Replies)
Discussion started by: number10
5 Replies

8. UNIX for Dummies Questions & Answers

comparison

hi guys i need a program that can compare a value read from a com-port and one from the terminal. can somebody help me??? using linux kernel 2.6.14-M5 can only use standard function in sh and bash... (5 Replies)
Discussion started by: metal005
5 Replies

9. Shell Programming and Scripting

While loop for comparison

hi all, i have two files: test1 contains : one two three four five (on separate lines) test2 contains: one ten nine (on separate lines) I want to compare two files, test1 against test2. if any word from test1 does not match test2 display it. can someone help me with a while loop on this. ... (4 Replies)
Discussion started by: sbk785
4 Replies

10. Shell Programming and Scripting

Help about comparison

Hello folks, I have two files, which have usernames, I want to see the contents of file1.txt which is missing in file2.txt and another comparison file2.txt contents which is missing in file1.txt. please suggest. file1.txt user u2 u8 a9 p9 p3 u4 z8 aaa ahe oktlo (7 Replies)
Discussion started by: learnbash
7 Replies
grass-mysql(1grass)						Grass User's Manual					       grass-mysql(1grass)

NAME
grass-mysql - MySQL driver MySQL driver MySQL driver in GRASS MySQL database driver in GRASS enables GRASS to store vector attributes in MySQL server. Because vector attribute tables are created automaticaly when a new vector is written and the name of the table is the same as the name of the vector it is good practice to create a new database for each GRASS mapset. Creating a MySQL database A new database is created within MySQL: mysql> CREATE DATABASE mydb; See the MySQL manual for details. Driver and database name GRASS modules require 2 parameters to connect to a database. Those parameters are 'driver' and 'database'. For MySQL driver the parameter 'driver' should be set to value 'mysql'. The parameter 'database' can be given in two formats: Database name - in case of connection from localhost String of comma separated list of kye=value options. Supported options are: dbname - database name host - host name or IP address port - server port number Examples of connection parameters: db.connect driver=mysql database=mytest db.connect driver=mysql database='dbname=mytest,host=test.grass.org' Data types GRASS supports almost all MySQL data types with following limitations: Binary columns (BINARY, VARBINARY, TINYBLOB, MEDIUMBLOB, BLOB, LONGBLOB) are not not supported. If a table with binary col- umn(s) is used in GRASS a warning is printed and only the supported columns are returned in query results. Columns of type SET and ENUM are represented as string (VARCHAR). Very large integers in columns of type BIGINT can be lost or corrupted because GRASS does not support 64 bin integeres on most platforms. GRASS does not currently distinguish types TIMESTAMP and DATETIME. Both types are in GRASS interpreted as TIMESTAMP. Indexes GRASS modules automaticaly create index on key column of vector attributes table. The index on key column is important for performance of modules which update the attribute table, for example v.to.db, v.distance and v.what.rast. Privileges Because MySQL does not support groups of users and because only MySQL 'root' can grant privileges to other users GRASS cannot automaticaly grant select privileges on created tables to group of users. If you want to give privilege to read data from your mapset to other users you have to ask your MySQL server administrator to grant select privilege to them on the MySQL database used for that mapset. For example, to allow everybody to read data in from your database 'mydb': shell> mysql --user=root mysql mysql> GRANT SELECT ON mydb.* TO ''@'%'; Schemas Because MySQL does not support database schemas the parameter 'schema' of module db.connect should never be set to any value. If you set that parameter for MySQL driver GRASS will try to write tables to the specified schema which will result in errors. Groups MySQL does not support user groups. Any settings specified by 'group' parameter of module db.connect are ignored by GRASS for MySQL driver. SEE ALSO
db.connect, SQL support in GRASS GIS Credits Development of the driver was sponsored by Faunalia (Italy) as part of a project for ATAC. AUTHOR
Radim Blazek Last changed: $Date: 2011-02-07 18:59:50 +0100 (Mon, 07 Feb 2011) $ Help Index GRASS 6.4.2 grass-mysql(1grass)
All times are GMT -4. The time now is 11:14 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy