<linux Shell Raiders > discovering MySQL Database Script management system

Source: Internet
Author: User


Operator interface


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/59/4C/wKiom1TPEynz5sHJAAJnQpUCZlg554.jpg "title=" 1.png " alt= "Wkiom1tpeynz5shjaajnqpuczlg554.jpg"/>


This little system consists of 4 scripts altogether.

Sh
Function
Note
onekey.sh Main program, call other programs, provide functions externally

menu.sh Outline Menu

function.sh Provides an operational database interface

valid.sh Working with MySQL database, validating data


menu.sh

Stooped character Menu

#!/bin/bashfunction print_main_menu () {cat <<eof########################################  &NBSP;&NBSP;&NBSP;1) Create a database                &NBSP;&NBSP;&NBSP;&NBSP;##&NBSP;&NBSP;&NBSP;&NBSP;2) Import e-commerce data          &NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;##&NBSP;&NBSP;&NBSP;&NBSP;3) Create an e-commerce database and import data   ##    &NBSP;4) Verify the validity of the e-commerce data data     ##    5) Delete database                    ##    6) Print Menu                      ##    7) Exit                          ################################ ####### #EOF}


function.sh

#!/bin/bash# #版本: v1.0# Purpose: Create mysql  database and database table # Create a database  4 required parameters (User,password,database_name,charset) function  create_database_01 () {    user= "$"     password= "$"      ip= "$"     datebase_name= "$4"     database_charset= "UTF8"     mysql -h  $IP  -u  $USER  -p$PASSWORD <<EOF 2> /dev/null    create database  $DATEBASE _name charset= $DATABASE _charset; eof    if [[ $? -eq 0 ]]; then             echo  database $DATEBASE _name "Create success"          else            echo  "Database" $ Datebase_name "Create failed"             exit 1;  &NBSP;&NBSP;&NBSP;FI} #扫描The database folder in the regional directory, executed sequentially function init_database_02 () {    user= "$"      Password= "$"     ip= "$"     datebase_name= "$4"      Areacode= "$ $"     while read line;     do         mysql -h  $IP  -u  $USER  -p$PASSWORD  $DATEBASE _ name < $line  2>/dev/null    done < < (ls ./$AREACODE/*. SQL&NBSP;-RT)     if [[ $? -eq 0 ]]; then             echo  "Import data Success" toward $DATEBASE _name          else            echo   "Import data failed" toward $DATEBASE _name             exit  1;  &nbsP;&NBSP;FI} #删除数据库function  drop_database_02 () {    user= "$"      Password= "$"     ip= "$"     datebase_name= "$4"      mysql -h  $IP  -u  $USER  -p$PASSWORD <<EOF 2>/dev/null     drop database  $DATEBASE _name; eof    if [[ $? -eq 0 ]]; then             echo  "Database" $DATEBASE _name "Delete succeeded"          else            echo  "Database" $ Datebase_name "Delete Failed"             exit 1;  &NBSP;&NBSP;&NBSP;FI} #读取参数function  readstdin () {             read -p  "Please input ip[localhost]:"  ip            if [[ -z  "$ip"  ]];  then                ip= " localhost "            fi             read -p  "please input db login  User[root]: " username            if [[  -z  "$username"  ]]; then                 username= "Root"              fi            read -p  " Please input db login password: " password             read -p  "Please input db name:" &NBSP;DBNAME&NBSP;&NBSP;&NBSP;&NBSP;} 


valida.sh

#!/bin/bashdbname= "Test_jd_dspt_wh" nsrsbh= "420112568371402" mysql= "mysql -h 192.168.15.9 -u  root -p123456  $dbname "# $mysql  " use  $dbname "sql=" Select count (NSRSBH)  into   @v01  from dj_nsrxx where nsrsbh= $NSRSBH, select if (@v01 <=0, ' taxpayer identification number in Dj_ There are no records in the Nsrxx table ',                    ' Verify that the 01[taxpayer identification number exists in the DJ_NSRXX table] verified by!!! '); select dsptbm into  @dsptbm   from dj_nsrxx where nsrsbh= $NSRSBH, select  pt.dsptmc into  @dsptmc  from dj_dzswpt_kz kz ,dj_dzswpt pt where   kz.id =pt.id  and [email protected];select if (@dsptmc  is  Not null,concat (' Verification 02 through the taxpayer e-commerce platform information: ', @dsptmc), ' Verify that 02[taxpayer e-commerce platform information is empty] verification does not pass!!! '); select hy_dm into  @vhy   from dj_nsrxx where [email protected]; Select kpzt into  @vkpzt   from dj_nsrxx where [email protected];select  nsrzt_dm into  @vnsrzt  from dj_nsrxx where [email protected];select if ( @vhy!=5200, ' Taxpayer industry code is not equal to 5200 ', ' verify 03[taxpayer Industry code equals 5200] verify through!!! '); Select if (@vnsrzt!=21, ' Taxpayer status code is not equal to 21 ', ' Verify 04[taxpayer status code equals 21] Validate through!!! '); Select if (@vkpzt!=1, ' taxpayer invoicing status is not equal to 1 ', ' Verify 05[taxpayer invoicing status equals 1] verified by!!! '); Select count (1)  into  @nsrztcount  FROM fp_nsrzt WHERE SWJG_DM =  ( select sz_swjg_dm from dj_nsrxx where nsrsbh =  @vnsrsbh)  AND  nsrzt_dm =  @vnsrzt; select if (@nsrztcount <=0, ' taxpayer tax Authority [SZ_SWJG_DM] does not exist or status does not match taxpayer information ', ' verify 06[ The tax authority where the taxpayer is located SZ_SWJG_DM effective] verification through!!! '); select  ' All the above verification pass, can guarantee the success of the order can be issued; Select count (1)  into  @vjccount2  from fp_pz  PZ,&NBSP;FP_NSRJC&NBSP;JC&NBSP;WHERE&NBSP;JC. Nsrsbh=pz. Nsrsbh and pz. FPZL_DM=JC. Fpzl_dm and [email proteCted];select if (@vjccount2 <=0, ' taxpayer ticket type or balance is empty ', ' verify 07[taxpayer invoicing balance ' verified by!!! '); Select count (1)  into  @dymbcount  from dm_dymb mb where swjg_dm= (select  sz_swjg_dm from dj_nsrxx where [email protected]); Select if (@dymbcount < 4, ' The number of printing templates in the tax authorities less than 4 ', ' Verify 08[print template ' Validation through, does not guarantee that the template path valid!!! '); Select concat (' ____ ', pyfileurl)  as  ' Print template as follows ' &NBSP;FROM&NBSP;DM_DYMB&NBSP;MB&NBSP;WHERE&NBSP;SWJG _dm= (select sz_swjg_dm from dj_nsrxx where [email protected]); Select qzid  into  @vqzid  from fp_qzcx where [email protected];select if (@vqzid  is null, ' Taxpayer signature information does not exist ', ' verify 09[signature information] verified by!!! '); $mysql  -N -L -s -e  "$sql"


This article is from a "simple" blog, so be sure to keep this source http://dba10g.blog.51cto.com/764602/1610703

<linux Shell Raiders > discovering MySQL Database Script management system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.