Sponsored Content
Top Forums Shell Programming and Scripting How to read a text file line by line and insert into a database table? Post 302920431 by Corona688 on Thursday 9th of October 2014 11:23:12 AM
Old 10-09-2014
Bumping up posts or double posting is not permitted in these forums.

Please read the rules, which you agreed to when you registered, if you have not already done so.

You may receive an infraction for this. If so, don't worry, just try to follow the rules more carefully. The infraction will expire in the near future

Thank You.

The UNIX and Linux Forums.

(Original thread is here)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert text file at a certain line.

I need to insert a file called temp_impact (which has about 15 lines in it) to a file called 11.23cfg starting at line 33. I searched the forums and found the sed '34i\ test' 11.23cfg > newfile That will enter word test at the appropriate line, but i need the entire file dumped there. Any... (4 Replies)
Discussion started by: insania
4 Replies

2. Shell Programming and Scripting

Insert a line in a text file

So I need to write lines into line X of file X. I can get the file by doing: cfgnumber=$(cat -n -comm.cfg| grep -i "servicegroup_name 24x7-comunicacions") echo $cfgnumber it outputs the Line where it finds now I need to start writing something right bellow that line. thanks (10 Replies)
Discussion started by: 4scriptmoni
10 Replies

3. Shell Programming and Scripting

How to insert some constant text at beginig of each line within a text file.

Dear Folks :), I am new to UNIX scripting and I do not know how can I insert some text in the first column of a UNIX text file at command promtp. I can do this in vi editor by using this command :g/^/s//BBB_ e,g I have a file named as Test.dat and it containins below text: michal... (4 Replies)
Discussion started by: Muhammad Afzal
4 Replies

4. Shell Programming and Scripting

bash: read file line by line (lines have '\0') - not full line has read???

I am using the while-loop to read a file. The file has lines with null-terminated strings (words, actually.) What I have by that reading - just a first word up to '\0'! I need to have whole string up to 'new line' - (LF, 10#10, 16#A) What I am doing wrong? #make file 'grb' with... (6 Replies)
Discussion started by: alex_5161
6 Replies

5. Web Development

INSERT data to a Database Table from a text file

If you have a text file and if you want to Insert data to your Database Table, You can do it with these queries LOAD DATA LOCAL INFILE '/path/yourTextFile.txt' INTO TABLE yourTableName FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (0 Replies)
Discussion started by: sitex
0 Replies

6. Shell Programming and Scripting

Read text file line by line

Hi everyone, I am writing a BASH shell script that I will use to process data files. I have a text file that contains the names of the files to be processed, for example: cat filenames.txt file1 file2 file3 file4 file5 What I would like to do is set up a FOR loop within my script... (2 Replies)
Discussion started by: msb65
2 Replies

7. Shell Programming and Scripting

Shell script to read a text file line by line & process it...

Hi , I am trying to write an shell, which reads a text file (from a location) having a list of numbers of strictly 5 digits only ex: 33144 Now my script will check : 1) that each entry is only 5 digits & numeric only, no alphabets, & its not empty. 2)then it executes a shell script called... (8 Replies)
Discussion started by: new_to_shell
8 Replies

8. UNIX for Dummies Questions & Answers

Insert a line in a text file

I want to insert a line with text after the 9th line of a text file. How would I do this using sed or awk? (2 Replies)
Discussion started by: lost.identity
2 Replies

9. UNIX for Beginners Questions & Answers

Insert a line of text on nth line of a file

Hi All, I am using UNix Sun OS sun4u sparc SUNW,SPARC-Enterprise My intention is to insert a line of text after 13th line of every file inside a particular directory. While trying to do it for a single file , i am using sed sed '3 i this is the 4th line' filename sed: command garbled: 3... (5 Replies)
Discussion started by: gotamp
5 Replies

10. Shell Programming and Scripting

Shell script UNIX to read text file line by line

i have a text file as belows, it includes 2 columns, 1st is the column name, 2nd is the file_name data_file.txt column_name file_name col1 file1 col2 file2 col3 file1 col4 file1 col5 file2 now, i would like to... (4 Replies)
Discussion started by: tester111
4 Replies
MYSQLDUMP(1)						      General Commands Manual						      MYSQLDUMP(1)

NAME
mysqldump - text-based client for dumping or backing up mysql databases , tables and or data. USAGE
mysqldump [OPTIONS] database [tables] OR mysqldump [OPTIONS] --databases [OPTIONS] DB1 [DB2 DB3...] OR mysqldump [OPTIONS] --all-databases [OPTIONS] OPTION SYNOPSIS
mysqldump [-A|--all-databases] [-a|--all] [-#|--debug=...] [--character-sets-dir=...] [-?|--help] [-B|--databases] [-c|--complete-insert] [-C|--compress] [--default-character-set=...] [-e|--extended-insert] [--add-drop-table] [--add-locks] [--allow-keywords] [--delayed- insert] [-F|--flush-logs] [-f|--force] [-h|--host=...] [-l|--lock-tables] [-n|--no-create-db] [-t|--no-create-info] [-d|--no-data] [-O|--set-variablevar=option] [--opt] [-p|--password[=...]] [-P|--port=...] [-q|--quick] [-Q|--quote-names] [-S|--socket=...] [--tables] [-T|--tab=...] [-u|--user=#] [-v|--verbose] [-V|--version] [-w|--where=] [--delayed] [-e|--extended-insert] [--fields-terminated-by=...] [--fields-enclosed-by=...] [--fields-optionally-enclosed-by=...] [--fields-escaped-by=...] [--lines-terminated-by=...] [-v|--verbose] [-V|--version] [-O net_buffer_length=#, where # < 16M] DESCRIPTION
Dumping definition and data mysql database or table mysqldump supports by executing -A|--all-databases Dump all the databases. This will be same as --databases with all databases selected. -a|--all Include all MySQL specific create options. -#|--debug=... Output debug log. Often this is 'd:t:o,filename`. --character-sets-dir=... Directory where character sets are -?|--help Display this help message and exit. -B|--databases To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. -c|--complete-insert Use complete insert statements. -C|--compress Use compression in server/client protocol. --default-character-set=... Set the default character set -e|--extended-insert Allows utilization of the new, much faster INSERT syntax. --add-drop-table Add a 'drop table' before each create. --add-locks Add locks around insert statements. --allow-keywords Allow creation of column names that are keywords. --delayed-insert Insert rows with INSERT DELAYED. -F|--flush-logs Flush logs file in server before starting dump. -f|--force Continue even if we get an sql-error. -h|--host=... Connect to host. -l|--lock-tables Lock all tables for read. -n|--no-create-db will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given. -t|--no-create-info Don't write table creation info. -d|--no-data No row information. -O|--set-variable var=option give a variable a value. --help lists variables --opt Same as --add-drop-table --add-locks --all --extended-insert --quick --lock-tables -p|--password[=...] Password to use when connecting to server. If password is not given it's solicited on the tty. -P|--port=... Port number to use for connection. -q|--quick Don't buffer query, dump directly to stdout. -Q|--quote-names Quote table and column names with ` -S|--socket=... Socket file to use for connection. --tables Overrides option --databases(-B). -T|--tab=... Creates tab separated textfile for each table to given path. (creates .sql and .txt files). NOTE: This only works if mysqldump is run on the same machine as the mysqld daemon. -u|--user=# User for login if not current user. -v|--verbose Print info about the various stages. -V|--version Output version information and exit. -w|--where= dump only selected records; QUOTES mandatory! --delayed Insert rows with the INSERT DELAYED command. -e|--extended-insert Use the new multiline INSERT syntax. (Gives more compact and faster inserts statements.) --fields-terminated-by=... --fields-enclosed-by=... --fields-optionally-enclosed-by=... --fields-escaped-by=... --lines-terminated-by=... These options are used with the -T option and have the same meaning as the corresponding clauses for LOAD DATA INFILE. See Mysql manual section 7.23 LOAD DATA INFILE Syntax. -v|--verbose Verbose mode. Print out more information on what the program does. -V|--version Print version information and exit. -O net_buffer_length=#, where # < 16M When creating multi-row-insert statements (as with option --extended-insert or --opt ), mysqldump will create rows up to net_buf- fer_length length. If you increase this variable, you should also ensure that the max_allowed_packet variable in the MySQL server is bigger than the net_buffer_length. EXAMPLES
The most normal use of mysqldump is probably for making a backup of whole databases. See Mysql Manual section 21.2 Database Backups. mysqldump --opt database > backup-file.sql You can read this back into MySQL with: mysql database < backup-file.sql or mysql -e 'source /patch-to-backup/backup-file.sql' database However, it's also very useful to populate another MySQL server with information from a database: mysqldump --opt database | mysql --host=remote-host -C database It is possible to dump several databases with one command: mysqldump --databases database1 [ database2 database3... ] > my_databases.sql If all the databases are wanted, one can use: mysqldump --all-databases > all_databases.sql SEE ALSO
isamchk (1), isamlog (1), mysqlaccess (1), mysqladmin (1), mysqlbug (1), mysqld (1), mysqldump (1), mysqlshow (1), msql2mysql (1), perror (1), replace (1), safe_mysqld (1), which1 (1), zap (1), AUTHOR
Ver 1.0, distribution 3.23.29a Michael (Monty) Widenius (monty@tcx.se), TCX Datakonsult AB (http://www.tcx.se). This software comes with no warranty. Manual page by L. (Kill-9) Pedersen (kill-9@kill-9.dk), Mercurmedia Data Model Architect / system developer (http://www.mer- curmedia.com) 19 December 2000 MYSQLDUMP(1)
All times are GMT -4. The time now is 01:33 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy