I'm trying to make a table with Go and the "github.com/go-sql-driver/mysql" driver package and want to makes tables from the IDs that are preconfigured (like rte-432343
). It throws an error when there is a dash in the name. Is there a way around the error: 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 '-432343'
request := "CREATE TABLE " + *tablename + " ( dbid int(11) NOT NULL AUTO_INCREMENT, name text, PRIMARY KEY (dbid)) ENGINE=InnoDB DEFAULT CHARSET=latin1"
_, err := db.Exec(request)
if err != nil {
fmt.Println("error creating database table", *tablename, err)
}