ctdo.de/events.go

23 lines
482 B
Go

package main
func getEvents() []event {
dbValues := readDatabaseYML()
db := dbConnect(dbValues.username, dbValues.password, dbValues.address, dbValues.port, dbValues.database)
rows := dbQuerry(db, "SELECT * FROM events;")
events := []event{}
for rows.Next() {
Event := new(event)
err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date)
if err != nil {
panic(err.Error())
}
events = append(events, *Event)
}
return events
}