arsd.database

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:

	auto db = new Sqlite("file.db"); // see the implementations for constructors
	// then the interface, for any impl can be as simple as:

	foreach(row; db.query("SELECT id, name FROM people")) {
             string id = row[0];
	     string name = row[1];
	}

	db.query("INSERT INTO people (id, name) VALUES (?, ?)", 5, "Adam");

To convert to other types, just use std.conv.to since everything comes out of this as simple strings.

Public Imports

std.variant
public import std.variant;
Undocumented in source.
std.datetime
public import std.datetime;
Undocumented in source.

Members

Aliases

AliasHelper
alias AliasHelper(alias T) = T
Undocumented in source.

Classes

DataObject
class DataObject
Undocumented in source.
DatabaseException
class DatabaseException
Undocumented in source.
InsertBuilder
class InsertBuilder
Undocumented in source.
SelectBuilder
class SelectBuilder

WARNING: this is as susceptible to SQL injections as you would be writing it out by hand

SimpleDataObject
class SimpleDataObject(string tableToUse, fieldsToUse)

This creates an editable data object out of a simple struct.

SqlBuilder
class SqlBuilder
Undocumented in source.

Enums

DbNullable
enum DbNullable
Undocumented in source.
DbSave
enum DbSave
Undocumented in source.
UpdateOrInsertMode
enum UpdateOrInsertMode
Undocumented in source.

Functions

DataObjectField
string DataObjectField()

You can subclass DataObject if you want to get some compile time checks or better types.

createDataObjectFieldsFromAlias
string createDataObjectFieldsFromAlias()
Undocumented in source. Be warned that the author may not have intended to support it.
escapedVariants
string escapedVariants(Database db, string sql, Variant[string] t)
Undocumented in source. Be warned that the author may not have intended to support it.
escapedVariants
string escapedVariants(Database db, string sql, Variant[] t)

Note: ?n params are zero based!

fillData
void fillData(string delegate(string, string) setter, T obj, string name)
Undocumented in source. Be warned that the author may not have intended to support it.
fillData
void fillData(void delegate(string, string) setter, T obj, string name)
Undocumented in source. Be warned that the author may not have intended to support it.
fixupSqlForDataObjectUse
string fixupSqlForDataObjectUse(string sql, string[string] keyMapping)
Undocumented in source. Be warned that the author may not have intended to support it.
getCreateTable
string getCreateTable(string sql, string tableName)
Undocumented in source. Be warned that the author may not have intended to support it.
objectToDataObject
DataObject objectToDataObject(T t, Database db, string table)
Undocumented in source. Be warned that the author may not have intended to support it.
queryOneColumn
Ret queryOneColumn(Database db, string sql, T t)
Undocumented in source. Be warned that the author may not have intended to support it.
readWord
string readWord(string src)
Undocumented in source. Be warned that the author may not have intended to support it.
rowToObject
T rowToObject(Row row)
Undocumented in source. Be warned that the author may not have intended to support it.
toSql
string toSql(Database db, Variant a)
Undocumented in source. Be warned that the author may not have intended to support it.
toSql
string toSql(string s, Database db)
Undocumented in source. Be warned that the author may not have intended to support it.
toSql
string toSql(long s, Database db)
Undocumented in source. Be warned that the author may not have intended to support it.
typeinfoBugWorkaround
void typeinfoBugWorkaround()
Undocumented in source. Be warned that the author may not have intended to support it.
updateOrInsert
int updateOrInsert(Database db, string table, string[string] values, string where, UpdateOrInsertMode mode, string key)
Undocumented in source. Be warned that the author may not have intended to support it.
yield
string yield(string what)
Undocumented in source. Be warned that the author may not have intended to support it.

Interfaces

Database
interface Database
ResultSet
interface ResultSet
Undocumented in source.

Mixin templates

DataObjectConstructors
mixintemplate DataObjectConstructors()
Undocumented in source.
DatabaseOperations
mixintemplate DatabaseOperations(string table)
Undocumented in source.
StrictDataObject
mixintemplate StrictDataObject()
Undocumented in source.

Structs

Query
struct Query
Undocumented in source.
Row
struct Row
Undocumented in source.
StructFromCreateTable
struct StructFromCreateTable(string sql, string tableName)

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.)

varchar
struct varchar(size_t max)
Undocumented in source.

Templates

DataObjectFromSqlCreateTable
template DataObjectFromSqlCreateTable(string sql, string tableName)

Combines StructFromCreateTable and SimpleDataObject into a one-stop template. alias DataObjectFromSqlCreateTable(import("file.sql"), "my_table") MyTable;

Meta