qcad qt ecmajavascript sqlite3
javascript 封裝Qt sql API
/**
* Provides a connection to a SQLite database.
*
* \param connectionName The connection name to use.
*/
function DbConnection(connectionName) {
if (isNull(connectionName)) {
return;
}
this.db = QSqlDatabase.database(connectionName, false);
}
DbConnection.prototype.dump = function() {
var query = this.createQuery();
query.execQuery(".dump");
};
DbConnection.prototype.transaction = function() {
this.db.transaction();
};
DbConnection.prototype.commit = function() {
this.db.commit();
};
DbConnection.prototype.rollback = function() {
this.db.rollback();
};
/**
* Executes the given QSqlQuery or SQL string and handles errors if appropriate.
*/
DbConnection.prototype.execQuery = function(query) {
try {
var ret = false;
if (isString(query)) {
var sql = query;
query = new QSqlQuery(this.db);
ret = query.exec(sql);
}
else {
ret = query.exec();
}
if (!ret) {
qCritical("DbConnection.js:", "execQuery(): error:", query
.lastError().text());
qCritical("DbConnection.js:", "execQuery(): query failed:\n", query
.executedQuery());
debugger;
}
} catch (e) {
qCritical("DbConnection.js:", "execQuery(): exception:", e);
debugger;
}
return query;
};
/**
* \return New QSqlQuery object.
*/
DbConnection.prototype.createQuery = function() {
return new QSqlQuery(this.db);
};
DbConnection.prototype.prepareQuery = function(sql) {
var query = new QSqlQuery(this.db);
var ret = query.prepare(sql);
if (!ret) {
qCritical("DbConnection.js:", "prepareQuery(): SQL prepare failed:\n",
sql, "\n", query.lastError().text());
debugger;
}
return query;
};
DbConnection.prototype.vacuum = function(sql) {
var query = this.createQuery();
query.exec("VACUUM");
};
/**
* Converts the given QPixmap into a QByteArray for storage in a BLOB.
*/
DbConnection.pixmapToByteArray = function(pixmap) {
if (pixmap == undefined || pixmap == null) {
return null;
}
var ba = new QByteArray();
var buffer = new QBuffer(ba);
buffer.open(QIODevice.WriteOnly);
pixmap.save(buffer, "PNG"); // writes pixmap into ba in PNG format
return ba;
};
相關文章
- Python資料庫模組(sqlite3,SQLite3)Python資料庫SQLite
- windows安裝sqlite3WindowsSQLite
- ubuntu上使用sqlite3UbuntuSQLite
- ubuntu下安裝sqlite3UbuntuSQLite
- sqlite3資料庫操作SQLite資料庫
- lazarus 開啟 sqlite3資料SQLite
- Peewee Sqlite3 中文模糊查詢SQLite
- 【知識點】SQLite3總結SQLite
- SQLite3 匯出 CSV 檔案SQLite
- CentOS6.5安裝sqlite3CentOSSQLite
- android sqlite3 not found 解決總結AndroidSQLite
- php封裝db 類連線sqlite3PHP封裝SQLite
- SQLite3資料庫檔案結構解析SQLite資料庫
- Python標準庫14 資料庫 (sqlite3)Python資料庫SQLite
- Simple: SQLite3 中文結巴分詞外掛SQLite分詞
- QTQT
- Qt Creator匯入不同Qt版本QT
- SQLite 命令列客戶端 sqlite3 使用指南SQLite命令列客戶端
- Rails7、sqlite3 和 litestream組合Docker配置AISQLiteDocker
- cocos2dx之引入Sqlite3資料庫SQLite資料庫
- 怎樣在sqlite3上執行SQL語句SQLite
- Qt - Qt Creator下載與安裝QT
- Qt MetadataQT
- Qt MetaTypeInterfaceQT
- Qt FontQT
- [Python]_[初級]_[校驗查詢sqlite3資料庫]PythonSQLite資料庫
- 【QT】 Qt多執行緒的“那些事”QT執行緒
- QT Creator/QT Designer佈局自適應QT
- Qt開發Activex筆記(二):Qt呼叫Qt開發的Activex控制元件QT筆記控制元件
- gorm操作sqlite3,高併發讀寫如何避免鎖庫?GoORMSQLite
- SQLite3原始碼學習(32) WAL日誌詳細分析SQLite原始碼
- Qt 反射 newInstanceQT反射
- qt深入解析QT
- QT字串QStringQT字串
- QT入門QT
- QT beginner QFileDialogQT
- QT開發QT
- Qt qSin()用法QT