Does a Go Mysql driver exist that supports multiple statements within a single string?

前端 未结 5 2122
生来不讨喜
生来不讨喜 2020-12-18 04:44

I\'m trying to find a MySql driver that i can use with Go which supports issuing multiple SQL statements in one call. For example i might wish to create a database using the

5条回答
  •  温柔的废话
    2020-12-18 05:16

    Adding an example for the answer from @ithkuil regarding multiStatements for the go-sql-driver package for reference. (I didn't have enough rep to add as a comment).

    The parameter for multiStatements is added onto the dataSourceName string for your sql.Open call. e.g.

    db, err := sql.Open("mysql", "user:pass@tcp(localhost:3306)/dbname?multiStatements=true")
    

    It's recommended that you not use such a db handler for processing user input, but it works great for processing known sql files.

提交回复
热议问题