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;
};
相關文章
- 使用sqlite3 模組操作sqlite3資料庫SQLite資料庫
- Python資料庫模組(sqlite3,SQLite3)Python資料庫SQLite
- Python3資料庫模組(sqlite3,SQLite3)Python資料庫SQLite
- Linux Sqlite3LinuxSQLite
- ubuntu上使用sqlite3UbuntuSQLite
- windows安裝sqlite3WindowsSQLite
- SQLite3 使用教學SQLite
- SQLITE3 使用總結SQLite
- ubuntu下安裝sqlite3UbuntuSQLite
- sqlite3資料庫操作SQLite資料庫
- iOS開發-sqlite3使用iOSSQLite
- 【知識點】SQLite3總結SQLite
- CentOS6.5安裝sqlite3CentOSSQLite
- SQLite3 匯出 CSV 檔案SQLite
- Peewee Sqlite3 中文模糊查詢SQLite
- lazarus 開啟 sqlite3資料SQLite
- 什麼是qt,QT Creator, QT SDK, QT DesignerQT
- python sqlite3 資料庫操作PythonSQLite資料庫
- C++ 操作sqlite3資料庫C++SQLite資料庫
- django之sqlite3常見錯誤DjangoSQLite
- php封裝db 類連線sqlite3PHP封裝SQLite
- android sqlite3 not found 解決總結AndroidSQLite
- 讓 Python 更加充分的使用 Sqlite3PythonSQLite
- qt呼叫js,js呼叫qtQTJS
- Qt:QT右鍵選單QT
- QT父子與QT物件deleteQT物件delete
- QTQT
- Simple: SQLite3 中文結巴分詞外掛SQLite分詞
- sqlite3在ubuntu的終端下面的操作SQLiteUbuntu
- SQLite3資料庫檔案結構解析SQLite資料庫
- Qt入門(11)——Qt外掛QT
- Qt Creator匯入不同Qt版本QT
- Python標準庫14 資料庫 (sqlite3)Python資料庫SQLite
- Rails7、sqlite3 和 litestream組合Docker配置AISQLiteDocker
- 怎樣在sqlite3上執行SQL語句SQLite
- SQLite 命令列客戶端 sqlite3 使用指南SQLite命令列客戶端
- python用sqlite3模組操作sqlite資料庫PythonSQLite資料庫
- Qt入門(12)——Qt國際化QT