title: "no such table" error with in-memory sqlite
body: <p>I am using in-memory sqlite as follows. </p>
  
  <pre><code>func init() {
      global.ConductorConfig = readConfig()
      log.Println(utils.GetCurrentDir() + global.ConductorConfig.DbFile)
      //db = sqlx.MustConnect("sqlite3", utils.GetCurrentDir()+global.ConductorConfig.DbFile)
      db = sqlx.MustConnect("sqlite3", ":memory:")
      db.Exec(schema)
      task:=model.Task{}
      SaveTask(&amp;task)
      db.MapperFunc(func(s string) string {
          return s
      })
  }
  </code></pre>
  
  <p>in my main func, I create the table </p>
  
  <pre><code>if global.ConductorConfig.DevMode {
      db.CreateTables()
  }
  go job.HeartbeatJob()
  go job.TaskClearJob()
  app.Action = func(c *cli.Context) error {
      ListenAndServe()
      return nil
  }
  </code></pre>
  
  <p>Then I go 'no such table' in http handler function.</p>
  
  <pre><code>existed, err := db.GetAgentByServerName(agent.ServerName)
  if err != nil {
      c.JSON(http.StatusBadRequest, err)
      log.Println("[conductor] error occurred when get agent by server name: " + err.Error())
      return err
  }
  
  
  func GetAgentByServerName(name string) (*model.Agent, error) {
      agent := &amp;model.Agent{}
      err := db.Get(agent, "select * from agent where ServerName=$1", name)
  
      if err == sql.ErrNoRows {
          err = nil
          agent = nil
      }
  
      return agent, err
  }
  </code></pre>
  
  <p>When I start the program, I got </p>
  
  <blockquote>
    <p>error occurred when get agent by server name: no such table: agent</p>
  </blockquote>
  
  <p>db schema (attributes omitted)</p>
  
  <pre><code>var schema = `
  DROP TABLE IF EXISTS agent;
  CREATE TABLE agent (
      Id                  INTEGER PRIMARY KEY,
  );
  
  DROP TABLE IF EXISTS task;
  CREATE TABLE task (
      Id                  INTEGER PRIMARY KEY,
  );
  </code></pre>
  
  <p>I can not share all the code, here is a minimal example to reproduce the same error. </p>
  
  <pre><code>    package main
  
      import (
          "github.com/jmoiron/sqlx"
          _ "github.com/mattn/go-sqlite3"
          "log"
      )
  
      var db *sqlx.DB
  
      func init() {
          db = sqlx.MustConnect("sqlite3", ":memory:")
          db.Exec("CREATE TABLE agent (Id  INTEGER PRIMARY KEY,);")
      }
  
      func main()  {
          _, err:=db.Exec("insert into agent values (1)")
          if err!=nil{
              log.Println(err)
          }
  
  }
  </code></pre>