Documentation ¶
Index ¶
- func CreateTable(db *sql.DB, createString string)
- func FetchLatest(db *sql.DB, querySQL string, thermometer string, ...) (thermometers.Reading, error)
- func PrepareStatement(db *sql.DB, statement string) (*sql.Tx, *sql.Stmt)
- type CalorDB
- type PostgresDB
- type SqliteDB
- func (sqldb SqliteDB) Between(name string, timestampRange UnixTimestampRange) ([]thermometers.Reading, error)
- func (sqlite SqliteDB) DB() *sql.DB
- func (sqlite SqliteDB) Init()
- func (sqldb SqliteDB) InsertReading(reading thermometers.Reading)
- func (sqldb SqliteDB) Latest(thermometer string) (thermometers.Reading, error)
- type UnixTimestampRange
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateTable ¶ added in v0.0.10
CreateTable creates the table(s) required for calor
func FetchLatest ¶ added in v0.0.10
func FetchLatest(db *sql.DB, querySQL string, thermometer string, readingMaker func(rows *sql.Rows) thermometers.Reading) (thermometers.Reading, error)
Fetches a single reading from the DB
Types ¶
type CalorDB ¶
type CalorDB interface { Init() Latest(thermometer string) (thermometers.Reading, error) InsertReading(reading thermometers.Reading) Between(name string, timestampRange UnixTimestampRange) ([]thermometers.Reading, error) }
A CalorDB implements the functions required to record and read back readings from calor thermometers
type PostgresDB ¶ added in v0.0.10
type PostgresDB struct {
// contains filtered or unexported fields
}
func CreatePostgresDB ¶ added in v0.0.10
func CreatePostgresDB(user string, password string, host string) PostgresDB
func (PostgresDB) Between ¶ added in v0.0.10
func (psql PostgresDB) Between(name string, timestampRange UnixTimestampRange) ([]thermometers.Reading, error)
ALL of the DBS will share a similar between, but they'll differ in how they process dates because they'll represent dates differently
func (PostgresDB) Init ¶ added in v0.0.10
func (psql PostgresDB) Init()
func (PostgresDB) InsertReading ¶ added in v0.0.10
func (psql PostgresDB) InsertReading(reading thermometers.Reading)
func (PostgresDB) Latest ¶ added in v0.0.10
func (psql PostgresDB) Latest(thermometer string) (thermometers.Reading, error)
type SqliteDB ¶
type SqliteDB struct {
// contains filtered or unexported fields
}
A SqliteDB is a CalorDB that is backed by a SqliteDB file
func CreateSqliteDB ¶
func (SqliteDB) Between ¶
func (sqldb SqliteDB) Between(name string, timestampRange UnixTimestampRange) ([]thermometers.Reading, error)
func (SqliteDB) InsertReading ¶
func (sqldb SqliteDB) InsertReading(reading thermometers.Reading)
type UnixTimestampRange ¶
Some DB drivers are weird about dates (SQLITE), hence when we query we'd like to do so with integers representing exact unix timestamp
Click to show internal directories.
Click to hide internal directories.