title: Does a Go Mysql driver exist that supports multiple statements within a single string?
body: <p>I'm trying to find a MySql driver that i can use with <a href="https://golang.org/" rel="noreferrer">Go</a> which supports issuing multiple SQL statements in one call. For example i might wish to create a database using the following SQL:</p>
  
  <pre><code>DROP SCHEMA IF EXISTS foo;
  CREATE SCHEMA IF NOT EXISTS foo;
  </code></pre>
  
  <p>In languages such as PHP you can just place both SQL statements in one string and execute it in one go, like this:</p>
  
  <pre><code>$db = new PDO(...);
  $db-&gt;query("DROP SCHEMA IF EXISTS foo; CREATE SCHEMA IF NOT EXISTS foo;");
  </code></pre>
  
  <p>The reason i need this is because i have SQL dumps (from <code>mysqldump</code>) i'd like to apply programmatically to various databases.</p>
  
  <p>I'm looking for the same functionality in Go but it seems all the different drivers don't support it, which, frankly, is shocking to me.</p>
  
  <p><strong>Go-MySQL-Driver</strong><br>
  <a href="https://github.com/go-sql-driver/mysql" rel="noreferrer">https://github.com/go-sql-driver/mysql</a><br>
  This seems to be the most used driver for Go.</p>
  
  <pre><code>package main
  
  import "database/sql"
  import "log"
  import _ "github.com/go-sql-driver/mysql"
  
  func main() {
  
      db, err := sql.Open("mysql", "user:password@(127.0.0.1:3306)/")
      if err != nil {
          log.Println(err)
      }
  
      sql := "DROP SCHEMA IF EXISTS foo; CREATE SCHEMA IF NOT EXISTS foo;"
      _, err = db.Exec(sql)
      if err != nil {
          log.Println(err)
      }
  
      db.Close()
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>2015/02/16 18:58:08 Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CREATE SCHEMA IF NOT EXISTS foo' at line 1
  </code></pre>
  
  <p><strong>MyMySQL</strong><br>
  <a href="https://github.com/ziutek/mymysql" rel="noreferrer">https://github.com/ziutek/mymysql</a><br>
  This is another popular driver.</p>
  
  <pre><code>package main
  
  import "database/sql"
  import "log"
  import _ "github.com/ziutek/mymysql/godrv"
  
  func main() {
  
      db, err := sql.Open("mymysql", "database/user/password")
      if err != nil {
          log.Println(err)
      }
  
      sql := "DROP SCHEMA IF EXISTS foo; CREATE SCHEMA IF NOT EXISTS foo;"
      _, err = db.Exec(sql)
      if err != nil {
          log.Println(err)
      }
  
      sql = "USE DATABASE foo;"
      _, err = db.Exec(sql) // &lt;-- error
      if err != nil {
          log.Println(err)
      }
  
      db.Close()
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>2015/02/16 18:58:08 packet sequence error
  </code></pre>
  
  <p>Does anyone know of any MySql driver compatible with Go that can handle multiple statements in one string like these?</p>