Skip to the content.

API Reference

Global Configuration

QueryKit.configure { |config| ... }

Configure QueryKit with a block.

QueryKit.configure do |config|
  config.adapter = :sqlite
  config.connection_options = { database: 'app.db' }
end

QueryKit.setup(adapter, options)

Shorthand configuration.

QueryKit.setup(:sqlite, database: 'app.db')
QueryKit.setup(:postgresql, host: 'localhost', dbname: 'mydb', user: 'postgres', password: 'pass')
QueryKit.setup(:mysql, host: 'localhost', database: 'mydb', username: 'root', password: 'pass')

QueryKit.connection

Get the global connection. Raises QueryKit::ConfigurationError if not configured.

QueryKit.reset!

Reset configuration and connection (useful for testing).

QueryKit.connect(adapter, options)

Create a new connection without global configuration.

Query Builder

SELECT

INSERT

UPDATE

DELETE

Connection

Repository

Class Methods

Instance Methods

Adapters

Three built-in adapters:

SQLiteAdapter

QueryKit.connect(:sqlite, 'database.db')
QueryKit.connect(:sqlite, ':memory:')

PostgreSQLAdapter

QueryKit.connect(:postgresql, host: 'localhost', dbname: 'mydb', user: 'postgres', password: 'pass')

MySQLAdapter

QueryKit.connect(:mysql, host: 'localhost', database: 'mydb', username: 'root', password: 'pass')

Return Values

Exceptions