39 lines
772 B
D
39 lines
772 B
D
|
module source.dblite;
|
||
|
|
||
|
import arsd.sqlite;
|
||
|
import std.stdio;
|
||
|
|
||
|
alias dblite = DBLite.getConnection;
|
||
|
|
||
|
class DBLite : Sqlite {
|
||
|
private:
|
||
|
static DBLite _dblite;
|
||
|
this(string database) {
|
||
|
super(database);
|
||
|
}
|
||
|
public:
|
||
|
@property static DBLite getConnection(string database = null) {
|
||
|
if (this._dblite is null) {
|
||
|
try {
|
||
|
this._dblite = new DBLite(database);
|
||
|
} catch (Exception e) {
|
||
|
throw new Exception(e.msg);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return this._dblite;
|
||
|
}
|
||
|
|
||
|
SqliteResult sql(T...)(string query, T t) {
|
||
|
return cast(SqliteResult)this.query(query, t);
|
||
|
}
|
||
|
|
||
|
void commit() {
|
||
|
this.query("COMMIT");
|
||
|
}
|
||
|
|
||
|
void rollback() {
|
||
|
this.query("ROLLBACK");
|
||
|
}
|
||
|
}
|