Browse Source

fmt

pull/7185/head
chrislu 1 month ago
parent
commit
ec7efe0652
  1. 2
      weed/command/s3.go
  2. 20
      weed/command/sql.go

2
weed/command/s3.go

@ -250,7 +250,7 @@ func (s3opt *S3Options) startS3Server() bool {
} else { } else {
glog.V(0).Infof("Starting S3 API Server with standard IAM") glog.V(0).Infof("Starting S3 API Server with standard IAM")
} }
s3ApiServer, s3ApiServer_err = s3api.NewS3ApiServer(router, &s3api.S3ApiServerOption{ s3ApiServer, s3ApiServer_err = s3api.NewS3ApiServer(router, &s3api.S3ApiServerOption{
Filer: filerAddress, Filer: filerAddress,
Port: *s3opt.port, Port: *s3opt.port,

20
weed/command/sql.go

@ -51,12 +51,12 @@ Examples:
} }
var ( var (
sqlServer = cmdSql.Flag.String("server", "localhost:8888", "SeaweedFS server address")
sqlServer = cmdSql.Flag.String("server", "localhost:8888", "SeaweedFS server address")
sqlInteractive = cmdSql.Flag.Bool("interactive", false, "start interactive shell mode") sqlInteractive = cmdSql.Flag.Bool("interactive", false, "start interactive shell mode")
sqlFile = cmdSql.Flag.String("file", "", "execute SQL queries from file")
sqlOutput = cmdSql.Flag.String("output", "", "output format: table, json, csv (auto-detected if not specified)")
sqlDatabase = cmdSql.Flag.String("database", "", "default database context")
sqlQuery = cmdSql.Flag.String("query", "", "execute single SQL query")
sqlFile = cmdSql.Flag.String("file", "", "execute SQL queries from file")
sqlOutput = cmdSql.Flag.String("output", "", "output format: table, json, csv (auto-detected if not specified)")
sqlDatabase = cmdSql.Flag.String("database", "", "default database context")
sqlQuery = cmdSql.Flag.String("query", "", "execute single SQL query")
) )
// OutputFormat represents different output formatting options // OutputFormat represents different output formatting options
@ -64,7 +64,7 @@ type OutputFormat string
const ( const (
OutputTable OutputFormat = "table" OutputTable OutputFormat = "table"
OutputJSON OutputFormat = "json"
OutputJSON OutputFormat = "json"
OutputCSV OutputFormat = "csv" OutputCSV OutputFormat = "csv"
) )
@ -79,11 +79,11 @@ type SQLContext struct {
func runSql(command *Command, args []string) bool { func runSql(command *Command, args []string) bool {
// Initialize SQL engine // Initialize SQL engine
sqlEngine := engine.NewSQLEngine(*sqlServer) sqlEngine := engine.NewSQLEngine(*sqlServer)
// Determine execution mode and output format // Determine execution mode and output format
interactive := *sqlInteractive || (*sqlQuery == "" && *sqlFile == "") interactive := *sqlInteractive || (*sqlQuery == "" && *sqlFile == "")
outputFormat := determineOutputFormat(*sqlOutput, interactive) outputFormat := determineOutputFormat(*sqlOutput, interactive)
// Create SQL context // Create SQL context
ctx := &SQLContext{ ctx := &SQLContext{
engine: sqlEngine, engine: sqlEngine,
@ -130,7 +130,7 @@ func executeSingleQuery(ctx *SQLContext, query string) bool {
// Suppress banner for non-interactive output // Suppress banner for non-interactive output
return executeAndDisplay(ctx, query, false) return executeAndDisplay(ctx, query, false)
} }
fmt.Printf("Executing query against %s...\n", *sqlServer) fmt.Printf("Executing query against %s...\n", *sqlServer)
return executeAndDisplay(ctx, query, true) return executeAndDisplay(ctx, query, true)
} }
@ -149,7 +149,7 @@ func executeFileQueries(ctx *SQLContext, filename string) bool {
// Split file content into individual queries (simple approach) // Split file content into individual queries (simple approach)
queries := strings.Split(string(content), ";") queries := strings.Split(string(content), ";")
for i, query := range queries { for i, query := range queries {
query = strings.TrimSpace(query) query = strings.TrimSpace(query)
if query == "" { if query == "" {

Loading…
Cancel
Save