Mercurial > mercurial > hgweb_rsearcher.cgi
comparison go/extsql.go @ 13:f5ffc34f045a
manage DB.
| author | pyon@macmini |
|---|---|
| date | Wed, 14 Nov 2018 19:43:40 +0900 |
| parents | 240752cbe11b |
| children |
comparison
equal
deleted
inserted
replaced
| 12:240752cbe11b | 13:f5ffc34f045a |
|---|---|
| 1 /* | 1 /* |
| 2 extsql.go : manipulate sqlite3. | 2 extsql.go : manipulate sqlite3. |
| 3 Version : 0.1 | 3 Version : 0.1 |
| 4 Last Change: 2018-11-13 火 15:22:56. | 4 Last Change: 2018-11-14 水 13:48:23. |
| 5 | 5 |
| 6 install to: rsearcher_root/ | 6 install to: rsearcher_root/ |
| 7 */ | 7 */ |
| 8 package main | 8 package main |
| 9 | 9 |
| 28 var printver = flag.Bool( "v", false, "print version" ) // print version | 28 var printver = flag.Bool( "v", false, "print version" ) // print version |
| 29 flag.Parse() | 29 flag.Parse() |
| 30 | 30 |
| 31 // print version | 31 // print version |
| 32 if *printver { | 32 if *printver { |
| 33 fmt.Println( "mngdb [ ver", version, "]" ) | 33 fmt.Println( "extsql [ ver", version, "]" ) |
| 34 os.Exit( 0 ) | 34 os.Exit( 0 ) |
| 35 } | 35 } |
| 36 | 36 |
| 37 if flag.NArg() != 3 { | 37 if flag.NArg() != 3 { |
| 38 fmt.Fprint( os.Stderr, "argument error.\n" ) | 38 fmt.Fprint( os.Stderr, "argument error.\n" ) |
| 68 hhsdb, err := exec.Command( sqlite, hhs, sql ).Output() | 68 hhsdb, err := exec.Command( sqlite, hhs, sql ).Output() |
| 69 if err != nil { | 69 if err != nil { |
| 70 log.Fatal( err ) | 70 log.Fatal( err ) |
| 71 } | 71 } |
| 72 | 72 |
| 73 f, _ = os.Create( "hhs.csv" ) | 73 f, _ = os.Create( "hhs.csv.tmp" ) |
| 74 for _, cols := range strings.Split( string( hhsdb ), "\n" ) { | 74 for _, cols := range strings.Split( string( hhsdb ), "\n" ) { |
| 75 col := strings.Split( cols, "|" ) | 75 col := strings.Split( cols, "|" ) |
| 76 if _, ok := m[ col[0] ]; ok == true { | 76 if _, ok := m[ col[0] ]; ok == true { |
| 77 buf := strings.Replace( cols, "|", ",", -1 ) + "\n" | 77 buf := strings.Replace( cols, "|", ",", -1 ) + "\n" |
| 78 f.WriteString( buf ) | 78 f.WriteString( buf ) |
