mirror of
https://github.com/nxshock/csv2db.git
synced 2024-11-27 03:31:00 +05:00
Add table name validation
This commit is contained in:
parent
06139693c6
commit
3606f38890
5
main.go
5
main.go
@ -4,6 +4,7 @@ import (
|
||||
"bufio"
|
||||
"database/sql"
|
||||
"encoding/csv"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@ -74,6 +75,10 @@ var app = &cli.App{
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
if len(strings.Split(c.String("table"), ".")) != 2 {
|
||||
return errors.New("table name must be in schema.name format")
|
||||
}
|
||||
|
||||
var err error
|
||||
|
||||
db, err = sql.Open("sqlserver", fmt.Sprintf("sqlserver://%s?database=%s", c.String("server"), c.String("database")))
|
||||
|
Loading…
Reference in New Issue
Block a user