A ConnectionPool manages a set of shared connections to a database.
Thrown when you use result data incorrectly. These almost always are preventable, but may be the result of a schema change and a select * query too.
Thrown when something is wrong with your connection to the database server.
Parent class of various forms of errors you can get when using the database.d library. It may be thrown generically when other details are not provided by a driver.
Unittest utility that returns a predefined set of values
WARNING: this is as susceptible to SQL injections as you would be writing it out by hand
This creates an editable data object out of a simple struct.
Thrown when your sql query has reached the database server, but failed to run there for some reason.
You can subclass DataObject if you want to get some compile time checks or better types.
Helpers for interpolated queries.
Note: ?n params are zero based!
Converts a database result set to a html table, using arsd.dom.
Helpers for interpolated queries.
Easy interop with arsd.cgi serveRestObject classes.
Represents a single item in a result. A row is a set of these DatabaseDatums.
PooledConnection is an RAII holder for a database connection that is automatically recycled to the pool it came from (unless you discard it).
A row in a result set from a query.
Given some SQL, it finds the CREATE TABLE instruction for the given tableName. (this is so it can find one entry from a file with several SQL commands. But it may break on a complex file, so try to only feed it simple sql files.)
Combines StructFromCreateTable and SimpleDataObject into a one-stop template. alias DataObjectFromSqlCreateTable(import("file.sql"), "my_table") MyTable;
Originally written prior to 2011.
On August 2, 2022, the behavior of BLOB (or BYTEA in postgres) changed significantly. Before, it would convert to strings with to!string(bytes) on insert and platform specific on query. It didn't really work at all.
It now actually stores ubyte[] as a blob and retrieves it without modification. Note you need to cast it.
This is potentially breaking, but since it didn't work much before I doubt anyone was using it successfully but this might be a problem. I advise you to retest.
Be aware I don't like this string interface much anymore and want to change it significantly but idk how to work it in without breaking a decade of code.
On June 7, 2023 (dub 11.0), I started the process of moving away from strings as the inner storage unit. This is a potentially breaking change, but you can use .toString to convert as needed and alias this will try to do this automatically in many situations. See DatabaseDatum for details. This transition is not yet complete.
Notably, passing it to some std.string functions will cause errors referencing DatabaseDatum like:
Error: template std.array.replace cannot deduce function from argument types !()(string, string, DatabaseDatum)
path/phobos/std/array.d(2459): Candidates are: replace(E, R1, R2)(E[] subject, R1 from, R2 to)
with `E = immutable(char),
R1 = string,
R2 = DatabaseDatum`Because templates do not trigger alias this - you will need to call .toString() yourself at the usage site.
Generic interface for RDBMS access. Use with one of the implementations in arsd.mysql, arsd.sqlite, arsd.postgres, or arsd.mssql. I'm sorry the docs are not good, but a little bit goes a long way:
To convert to other types, just use std.conv.to since everything comes out of this as simple strings with the exception of binary data, which you'll want to cast to const(ubyte)[].