I am trying to do a simple thing, check if there is a table, if not then create that table in database.
Here this is the logic I used.
test := "June_2019"
sql_query := `select * from ` + test + `;`
read_err := db.QueryRow(sql_query, 5)
error_returned := read_err.Scan(read_err)
defer db.Close()
if error_returned == nil {
fmt.Println("table is there")
} else {
fmt.Println("table not there")
}
In my database I have June_2019
table. But still this code returns me not nil
value. I used db.QueryRow(sql_query, 5)
5 as I have five colomns in my table.
What am I missing here? I am still learning golang.
Thanks in advance.