Documentation ¶
Overview ¶
sqlite is a package designed to interact specifically with the SQLite3 database engine. It is configured by default to use SQLite's "write to disk" functionality to store data in a flat file on the OS.
Index ¶
Constants ¶
const SEPARATOR = ","
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
DBClient is the atomic unit of interacting with SQLite.
func NewClient ¶
NewClient creates a client and opens a connection to a database. It allows for connection to arbitrarily named databases. It returns a pointer to a DBClient object if successful; an error otherwise.
filename is the name of the flat file where the data will be stored.
It returns a pointer to a DBClient object if successful; an error otherwise.
func (*Client) AddIPDetails ¶
AddIPDetails is the creation operation for adding new data to the database. It returns a representation of the object added to the database if successful; an error otherwise.
contract is the data model used by most of the system for IPDetails and represents the object to be stored.
It returns a representation of the object added to the database if successful; an error otherwise.
func (*Client) Close ¶
Close will attempt to close the database connection. This should usually be called with a defer statement when opening any connection to the database.
func (*Client) GetIPDetailByAddress ¶
GetIPDetailByAddress is the retrieval operation for getting data from the database. It returns a representation of the object requested in the database if successful; an error otherwise.
address is the IP address that we want to query the database for.
It returns a representation of the object requested in the database if successful; an error otherwise.
func (*Client) UpdateIPDetails ¶
UpdateIPDetails is the update operation for editing data to the database. It returns a representation of the object updated in the database if successful; an error otherwise.
contract is the data model used by most of the system for IPDetails and represents the object to be stored.
It returns a representation of the object updated it the database if successful; an error otherwise.
type IPDetails ¶
type IPDetails struct { ID string CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` ResponseCode string `db:"response_code"` IPAddress string `db:"ip_address"` }
IPDetails is a struct designed to make interacting with the database easier. The struct used by most of the system is close, but not quite what we need for interacting with the DB.