dstruct.ddbc.pods

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

Source file ddbc/drivers/pgsqldstruct.ddbc.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.

1 import dstruct.ddbc;
2 import std.stdio;
3 
4 // prepare database connectivity
5 auto conn = createConnection("sqlite:ddbctest.sqlite");
6 scope(exit) conn.close();
7 Statement stmt = conn.createStatement();
8 scope(exit) stmt.close();
9 // fill database with test data
10 stmt.executeUpdate("DROP TABLE IF EXISTS user");
11 stmt.executeUpdate("CREATE TABLE user (id INTEGER PRIMARY KEY, name VARCHAR(255) NOT NULL, flags int null)");
12 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)`);
13 
14 // our POD object
15 struct User {
16     long id;
17     string name;
18     int flags;
19 }
20 
21 writeln("reading all user table rows");
22 foreach(e; stmt.select!User) {
23     writeln("id:", e.id, " name:", e.name, " flags:", e.flags);
24 }
25 
26 writeln("reading user table rows with where and order by");
27 foreach(e; stmt.select!User.where("id < 6").orderBy("name desc")) {
28     writeln("id:", e.id, " name:", e.name, " flags:", e.flags);
29 }

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

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