readtest/source/dblite.d

39 lines
772 B
D
Raw Normal View History

2024-02-11 20:00:56 +00:00
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");
}
}