module
PgORM::Database
Extended Modules
Defined in:
pg-orm/database.crClass Method Summary
- .adapter(builder : Query::Builder) : PostgreSQL
- .begin_transaction : DB::Transaction
- .checkout : DB::Connection
-
.configure(&) : Nil
Configures database connection settings.
- .connection(&)
- .exec_sql(sql : String, *args_)
- .info : Info
-
.parse(uri : String | URI) : Nil
Parses a PostgreSQL connection URL and configures the database.
- .pool : DB::Database
- .quote(name : Symbol | String, io : IO)
- .quote(name : Symbol | String)
- .release : Nil
- .transaction(&)
- .with_connection(&)
Class Method Detail
def self.configure(&) : Nil
#
Configures database connection settings.
This also enables change data capture (CDC) for real-time notifications.
Example
PgORM::Database.configure do |settings|
settings.host = "db.example.com"
settings.port = 5432
settings.db = "production"
settings.user = "app_user"
settings.password = ENV["DB_PASSWORD"]
end
def self.parse(uri : String | URI) : Nil
#
Parses a PostgreSQL connection URL and configures the database.
This is the recommended way to configure the database in production, typically from an environment variable.
Example
# From environment variable
PgORM::Database.parse(ENV["DATABASE_URL"])
# Direct URL
PgORM::Database.parse("postgres://user:pass@localhost:5432/mydb")