Retrieving Data
SQL injection does not only concern the data being inserted. It also concerns any data that is manipulated in the database. Retrieving data and, most importantly, retrieving it safely is also something we must prioritize and handle with proper caution. When we query data, our results depend on the database we connect to and the table we would like to query. But we must also mention that the security mechanisms implemented by the database engine may also prevent a successful query unless the user has appropriate privileges. We differentiate two types of queries. There are queries that do not take an argument, such as SELECT * FROM table
, and there are queries that require you to specify filter criteria. Go provides two functions that allow you to query data. One is called the Query()
function and the other is called the QueryRow()
function. The availability of these functions depends on the database you are interacting with. As a rule of thumb, you should remember that...