mirror of
https://github.com/sstent/garminsync-go.git
synced 2026-01-26 17:11:53 +00:00
working build - no ui
This commit is contained in:
@@ -20,15 +20,15 @@ func NewSQLiteDB(dbPath string) (*SQLiteDB, error) {
|
||||
|
||||
sqlite := &SQLiteDB{db: db}
|
||||
|
||||
// Create tables
|
||||
if err := sqlite.createTables(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Create tables
|
||||
if err := sqlite.CreateTables(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return sqlite, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteDB) createTables() error {
|
||||
func (s *SQLiteDB) CreateTables() error {
|
||||
schema := `
|
||||
CREATE TABLE IF NOT EXISTS activities (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -134,6 +134,10 @@ func (s *SQLiteDB) ActivityExists(activityID int) (bool, error) {
|
||||
return count > 0, nil
|
||||
}
|
||||
|
||||
func (s *SQLiteDB) DB() *sql.DB {
|
||||
return s.db
|
||||
}
|
||||
|
||||
func (s *SQLiteDB) GetActivity(activityID int) (*Activity, error) {
|
||||
query := `
|
||||
SELECT id, activity_id, start_time, activity_type, duration, distance,
|
||||
|
||||
Reference in New Issue
Block a user