16
16
database = "SampleDB"
17
17
)
18
18
19
- // Create an employee
19
+ // CreateEmployee create an employee
20
20
func CreateEmployee (db * sql.DB , name string , location string ) (int64 , error ) {
21
21
tsql := fmt .Sprintf ("INSERT INTO TestSchema.Employees (Name, Location) VALUES ('%s','%s');" ,
22
22
name , location )
@@ -28,7 +28,7 @@ func CreateEmployee(db *sql.DB, name string, location string) (int64, error) {
28
28
return result .LastInsertId ()
29
29
}
30
30
31
- // Read all employees
31
+ // ReadEmployees read all employees
32
32
func ReadEmployees (db * sql.DB ) (int , error ) {
33
33
tsql := fmt .Sprintf ("SELECT Id, Name, Location FROM TestSchema.Employees;" )
34
34
rows , err := db .Query (tsql )
@@ -52,7 +52,7 @@ func ReadEmployees(db *sql.DB) (int, error) {
52
52
return count , nil
53
53
}
54
54
55
- // Update an employee's information
55
+ // UpdateEmployee update an employee's information
56
56
func UpdateEmployee (db * sql.DB , name string , location string ) (int64 , error ) {
57
57
tsql := fmt .Sprintf ("UPDATE TestSchema.Employees SET Location = '%s' WHERE Name= '%s'" ,
58
58
location , name )
@@ -64,7 +64,7 @@ func UpdateEmployee(db *sql.DB, name string, location string) (int64, error) {
64
64
return result .LastInsertId ()
65
65
}
66
66
67
- // Delete an employee from database
67
+ // DeleteEmployee delete an employee from database
68
68
func DeleteEmployee (db * sql.DB , name string ) (int64 , error ) {
69
69
tsql := fmt .Sprintf ("DELETE FROM TestSchema.Employees WHERE Name='%s';" , name )
70
70
result , err := db .Exec (tsql )
0 commit comments