package spin:postgres@3.0.0; interface postgres { /// Errors related to interacting with a database. variant error { connection-failed(string), bad-parameter(string), query-failed(string), value-conversion-failed(string), other(string) } /// Data types for a database column enum db-data-type { boolean, int8, int16, int32, int64, floating32, floating64, str, binary, date, time, datetime, timestamp, other, } /// Database values variant db-value { boolean(bool), int8(s8), int16(s16), int32(s32), int64(s64), floating32(float32), floating64(float64), str(string), binary(list), date(tuple), // (year, month, day) time(tuple), // (hour, minute, second, nanosecond) /// Date-time types are always treated as UTC (without timezone info). /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. datetime(tuple), /// Unix timestamp (seconds since epoch) timestamp(s64), db-null, unsupported, } /// Values used in parameterized queries variant parameter-value { boolean(bool), int8(s8), int16(s16), int32(s32), int64(s64), floating32(float32), floating64(float64), str(string), binary(list), date(tuple), // (year, month, day) time(tuple), // (hour, minute, second, nanosecond) /// Date-time types are always treated as UTC (without timezone info). /// The instant is represented as a (year, month, day, hour, minute, second, nanosecond) tuple. datetime(tuple), /// Unix timestamp (seconds since epoch) timestamp(s64), db-null, } /// A database column record column { name: string, data-type: db-data-type, } /// A database row type row = list; /// A set of database rows record row-set { columns: list, rows: list, } /// A connection to a postgres database. resource connection { /// Open a connection to the Postgres instance at `address`. open: static func(address: string) -> result; /// Query the database. query: func(statement: string, params: list) -> result; /// Execute command to the database. execute: func(statement: string, params: list) -> result; } }