-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update sqlite to use a hand build schema #2305
Conversation
45de6c1
to
48467ed
Compare
2979667
to
c662385
Compare
@ozym I had a quick once over looking at the structs and a few of the sql queries where you might expect to call them, and it's not clear the sql queries are using the same field names. eg query for Are the fields being updated outside the structs before the sql queries are run? |
If this is for the example code, then usually the mechanism is to do the SQL query (with the details of the schema) and then pass each resulting line into an extraction which then maps the order of the query output values into variable fields, which tend to be part of a struct. e.g. query := "SELECT make.make,sensor.start_date,sensor.end_date FROM <snip> WHERE <snip>"; Then when you scan each row you can map them into a different structure, e.g. type Sensor struct {
Make string
Start time.Time
End time.Time
}
func() {
...
sensors := make([]Sensor, 0)
for results.Next() {
var sensor Sensor
if err := results.Scan(&sensor.Make, &sensor.Start, &sensor.End); err != nil {
error here.
}
sensors = append(sensors, sensor)
}
...
} etc. |
For added context, I haven't tried to build an ORM in which case, yes the field names should map to sql values. |
Cool thanks, I will have a proper read through |
a2fc3be
to
1a9c4ce
Compare
This is the next iteration on from the basic table layout, there has been more effort in normalisation. There are still some outstanding issues, one improvement would be to consolidate some of the tables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
This is the next iteration on from the basic table layout, there has been more effort in normalisation. There are still some outstanding issues, one improvement would be to consolidate some of the tables.