ddbc.pods

DDBC - D DataBase Connector - abstraction layer for RDBMS access, with interface similar to JDBC.

Source file ddbc/drivers/pgsqlddbc.d. DDBC library attempts to provide implementation independent interface to different databases.

Set of supported RDBMSs can be extended by writing Drivers for particular DBs.

JDBC documentation can be found here: http://docs.oracle.com/javase/1.5.0/docs/api/java/sql/package-summary.html

This module contains implementation POD utilities.

import ddbc;
import std.stdio;

// prepare database connectivity
auto conn = createConnection("sqlite:ddbctest.sqlite");
scope(exit) conn.close();
Statement stmt = conn.createStatement();
scope(exit) stmt.close();
// fill database with test data
stmt.executeUpdate("DROP TABLE IF EXISTS user");
stmt.executeUpdate("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255) NOT NULL, flags int null)");
stmt.executeUpdate(`INSERT INTO user (id, name, flags) VALUES (1, "John", 5), (2, "Andrei", 2), (3, "Walter", 2), (4, "Rikki", 3), (5, "Iain", 0), (6, "Robert", 1)`);

// our POD object
struct User {
    long id;
    string name;
    int flags;
}

writeln("reading all user table rows");
foreach(e; stmt.select!User) {
    writeln("id:", e.id, " name:", e.name, " flags:", e.flags);
}

writeln("reading user table rows with where and order by");
foreach(e; stmt.select!User.where("id < 6").orderBy("name desc")) {
    writeln("id:", e.id, " name:", e.name, " flags:", e.flags);
}

Members

Aliases

Byte
alias Byte = Nullable!byte
Undocumented in source.
Double
alias Double = Nullable!double
Undocumented in source.
Float
alias Float = Nullable!float
Undocumented in source.
Int
alias Int = Nullable!int
Undocumented in source.
Long
alias Long = Nullable!long
Undocumented in source.
NullableDate
alias NullableDate = Nullable!Date
Undocumented in source.
NullableDateTime
alias NullableDateTime = Nullable!DateTime
Undocumented in source.
NullableSysTime
alias NullableSysTime = Nullable!SysTime
Undocumented in source.
NullableTimeOfDay
alias NullableTimeOfDay = Nullable!TimeOfDay
Undocumented in source.
Short
alias Short = Nullable!short
Undocumented in source.
Ubyte
alias Ubyte = Nullable!ubyte
Undocumented in source.
Uint
alias Uint = Nullable!uint
Undocumented in source.
Ulong
alias Ulong = Nullable!ulong
Undocumented in source.
Ushort
alias Ushort = Nullable!ushort
Undocumented in source.

Enums

PropertyMemberType
enum PropertyMemberType
Undocumented in source.

Functions

addFieldValue
string addFieldValue(string m)
Undocumented in source. Be warned that the author may not have intended to support it.
addUpdateValue
string addUpdateValue(string m)
Undocumented in source. Be warned that the author may not have intended to support it.
camelCaseToUnderscoreDelimited
string camelCaseToUnderscoreDelimited(string s)

converts camel case MyEntityName to my_entity_name

generateDeleteSQL
string generateDeleteSQL()

returns "DELETE FROM <table name> WHERE id=id

generateInsertSQL
string generateInsertSQL()

returns "INSERT INTO <table name> (<field list>) VALUES (value list)

generateSelectForGetSQL
string generateSelectForGetSQL()

returns "SELECT <field list> FROM <table name>"

generateSelectForGetSQLWithFilter
string generateSelectForGetSQLWithFilter()
Undocumented in source. Be warned that the author may not have intended to support it.
generateSelectSQL
string generateSelectSQL()

returns "SELECT <field list> FROM <table name>"

generateSelectSQL
string generateSelectSQL()

returns "SELECT <field list> FROM <table name>"

generateUpdateSQL
string generateUpdateSQL()

returns "UPDATE <table name> SET field1=value1 WHERE id=id

get
T get(Statement stmt, long id)
Undocumented in source. Be warned that the author may not have intended to support it.
get
T get(Statement stmt, string filter)
Undocumented in source. Be warned that the author may not have intended to support it.
get
T get(ResultSet r)

Extract a row from the result set as the specified type. Requires that next has already been checked. Can be used for example to extract rows from executing a PreparedStatement.

getAllColumnsReadCode
string getAllColumnsReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getAllColumnsReadCode
string getAllColumnsReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getAllColumnsReadCodeByName
string getAllColumnsReadCodeByName()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnNamesForType
string[] getColumnNamesForType()

returns array of field names

getColumnReadCode
string getColumnReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnReadCodeByName
string getColumnReadCodeByName()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnTypeDatasetReadCode
string getColumnTypeDatasetReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnTypeDatasetReadCodeByName
string getColumnTypeDatasetReadCodeByName()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnTypeIsNullCode
string getColumnTypeIsNullCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getColumnTypeKeyIsSetCode
string getColumnTypeKeyIsSetCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyMemberType
PropertyMemberType getPropertyMemberType()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyReadCode
string getPropertyReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyReadCode
string getPropertyReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyType
PropertyMemberType getPropertyType()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyWriteCode
string getPropertyWriteCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyWriteCode
string getPropertyWriteCode()
Undocumented in source. Be warned that the author may not have intended to support it.
getPropertyWriteCodeByName
string getPropertyWriteCodeByName()
Undocumented in source. Be warned that the author may not have intended to support it.
getTableNameForType
string getTableNameForType()

returns table name for struct type

getVarTypeDatasetReadCode
string getVarTypeDatasetReadCode()
Undocumented in source. Be warned that the author may not have intended to support it.
insert
bool insert(Statement stmt, T o)
Undocumented in source. Be warned that the author may not have intended to support it.
isColumnTypeNullableByDefault
bool isColumnTypeNullableByDefault()
Undocumented in source. Be warned that the author may not have intended to support it.
isSupportedSimpleTypeRefList
bool isSupportedSimpleTypeRefList()
Undocumented in source. Be warned that the author may not have intended to support it.
joinFieldList
string joinFieldList()
Undocumented in source. Be warned that the author may not have intended to support it.
paramCount
int paramCount()
Undocumented in source. Be warned that the author may not have intended to support it.
remove
bool remove(Statement stmt, T o)
Undocumented in source. Be warned that the author may not have intended to support it.
update
bool update(Statement stmt, T o)
Undocumented in source. Be warned that the author may not have intended to support it.

Static variables

ColumnTypeCanHoldNulls
bool[] ColumnTypeCanHoldNulls;
Undocumented in source.
ColumnTypeDatasetReaderCode
string[] ColumnTypeDatasetReaderCode;
Undocumented in source.
ColumnTypeIsNullCode
string[] ColumnTypeIsNullCode;
Undocumented in source.
ColumnTypeKeyIsSetCode
string[] ColumnTypeKeyIsSetCode;
Undocumented in source.
ColumnTypePropertyToVariant
string[] ColumnTypePropertyToVariant;
Undocumented in source.
ColumnTypeSetNullCode
string[] ColumnTypeSetNullCode;
Undocumented in source.

Structs

String
struct String

Wrapper around string, to distinguish between Null and NotNull fields: string is NotNull, String is Null -- same interface as in Nullable

select
struct select(T, fieldList...)

range for select query

select
struct select(Args...)
Undocumented in source.

Templates

isSupportedSimpleType
template isSupportedSimpleType(T, string m)
Undocumented in source.
isSupportedSimpleTypeRef
template isSupportedSimpleTypeRef(M)
Undocumented in source.

Meta

Authors

Vadim Lopatin