123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package cmd
- import (
- "bufio"
- "database/sql"
- "fmt"
- "os"
- "strings"
- "xg_once_query/dbBase"
- )
- func view(db *sql.DB) {
-
- reader := bufio.NewReader(os.Stdin)
- for {
- fmt.Print("SQL> ")
- input, _ := reader.ReadString(';')
- input = strings.TrimLeft(input, " ")
- fmt.Printf("SQL =%s, end \n ", input)
- firstSpaceIndex := strings.Index(input, " ")
- if firstSpaceIndex != -1 {
- firstWord := input[:firstSpaceIndex]
- if strings.HasPrefix(strings.ToLower(firstWord), "select") {
- dbBase.DbQuery(db, input)
- } else {
- dbBase.DbExec(db, input)
- }
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
|