This shows how we can use the go-sql-driver (which uses the /sql interface) to form a connection to our server using the Open method.
Once we have our connection, we can create a statement of our SQL query, and to prevent SQL injection we send the parameters (values which should correspond with to the question marks in our query) separately along with the Exec method. Finally, calling the LastInsertId() we can get the of the row we’ve just inserted – and in our example, we output this value to screen.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here