AIT Database API¶
AIT provides a general database abstraction class on top of which custom implementations can be written. AIT comes packaged with abstractions for InfluxDB (ait.core.db.InfluxDBBackend
)and SQLite (ait.core.db.SQLiteBackend
). You can inherit from the abstract base class ait.core.db.GenericBackend
and implement your own database abstraction.
-
class
ait.core.db.
GenericBackend
¶ Generic database backend abstraction
GenericBackend attempts to adequately abstract database operations into a small set of common methods. Not all methods will be useful for every database type and additional methods may need to be added for future database support.
Generally, the expected method functionality should be
- connect
Connect to instance of the database via the backend driver. Five configuration options are respected by convention in AIT built-in backend implementations if they’re applicable to the given backend
- database.host
- The host to connect to. Defaults to localhost
- database.port
- The port to connect to. Defaults to technology specific value.
- database.un
- The username to use when connecting to the database. Defaults to a technology specific value.
- database.pw
- The password to use when connecting to the database. Defaults to a technology specific value.
- database.dbname
- The name of the database to create/use. Defaults to ait.
- create
- Create a database in the database instance
- insert
- Insert a packet into the database
- query
- Take a string defining a database query and return the results. The format of the results is backend specific.
- close
- Close the connection to the database instance and handle any cleanup