• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ database函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中database函数的典型用法代码示例。如果您正苦于以下问题:C++ database函数的具体用法?C++ database怎么用?C++ database使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了database函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: sql

// Remove privileges for $username from the entire database.
void Database_Privileges::removeUser (string username)
{
  SqliteDatabase sql (database ());
  sql.add ("DELETE FROM bibles WHERE username =");
  sql.add (username);
  sql.add (";");
  sql.execute ();
  sql.clear ();
  sql.add ("DELETE FROM features WHERE username =");
  sql.add (username);
  sql.add (";");
  sql.execute ();
}
开发者ID:bibledit,项目名称:bibledit-windows,代码行数:14,代码来源:privileges.cpp


示例2: QVERIFY

void TagDatabaseInMemoryTest::loadEmpty()
{
	QTemporaryFile file;
	QVERIFY(file.open());

	TagDatabaseInMemory database("tests/resources/tag-types.txt", file.fileName());
	QVERIFY(database.load());

	QMap<QString, TagType> types = database.getTagTypes(QStringList() << "tag1" << "tag3");

	QCOMPARE(types.count(), 0);
	QCOMPARE(database.count(), 0);
}
开发者ID:Flat,项目名称:imgbrd-grabber,代码行数:13,代码来源:tag-database-in-memory-test.cpp


示例3: debug

//////////////////////////////////////////////////////////////////////
// ProjectTable implementation
//////////////////////////////////////////////////////////////////////
ProjectRecord	ProjectTable::get(const std::string& name) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "retrieve project '%s'", name.c_str());
	std::string	condition = stringprintf("name = '%s'",
		database()->escape(name).c_str());
	std::list<ProjectRecord>	l = select(condition);
	if (0 == l.size()) {
		std::string	msg = stringprintf("no project '%s'",
			name.c_str());
		debug(LOG_DEBUG, DEBUG_LOG, 0, "%s", msg.c_str());
		throw std::runtime_error(msg);
	}
	return *(l.begin());
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:16,代码来源:ProjectTable.cpp


示例4: qCDebug

/**
 * @fn tryGetTask
 */
QueuedProcess *QueuedCorePrivateHelper::tryGetTask(const long long _id)
{
    qCDebug(LOG_LIB) << "Search for task" << _id;

    auto task = processes()->process(_id);
    if (!task) {
        qCInfo(LOG_LIB) << "Try to get information about task" << _id << "from database";
        auto data = database()->get(QueuedDB::TASKS_TABLE, _id);
        if (data.isEmpty()) {
            qCWarning(LOG_LIB) << "Could not find task with ID" << _id;
            return nullptr;
        }
        qCInfo(LOG_LIB) << "Try to get task" << _id << "modifications from database";
        auto mods
            = database()->get(QueuedDB::TASKS_MODS_TABLE, "WHERE task=:task", {{"task", _id}});

        auto defs = QueuedProcessManager::parseDefinitions(data, mods);
        task = new QueuedProcess(this, defs, _id);
    }

    return task;
}
开发者ID:arcan1s,项目名称:queued,代码行数:25,代码来源:QueuedCorePrivateHelper.cpp


示例5: ilog

void debug_node_plugin::plugin_startup()
{
   ilog("debug_node_plugin::plugin_startup() begin");
   chain::database& db = database();

   // connect needed signals

   _applied_block_conn  = db.applied_block.connect([this](const chain::signed_block& b){ on_applied_block(b); });
   _changed_objects_conn = db.changed_objects.connect([this](const std::vector<graphene::db::object_id_type>& ids){ on_changed_objects(ids); });
   _removed_objects_conn = db.removed_objects.connect([this](const std::vector<const graphene::db::object*>& objs){ on_removed_objects(objs); });

   app().register_api_factory< debug_node_api >( "debug_node_api" );
}
开发者ID:Bitcoinsulting,项目名称:steem,代码行数:13,代码来源:debug_node_plugin.cpp


示例6: database

void elasticsearch_plugin::plugin_initialize(const boost::program_options::variables_map& options)
{
   database().applied_block.connect( [&]( const signed_block& b){ my->update_account_histories(b); } );
   my->_oho_index = database().add_index< primary_index< operation_history_index > >();
   database().add_index< primary_index< account_transaction_history_index > >();

   if (options.count("elasticsearch-node-url")) {
      my->_elasticsearch_node_url = options["elasticsearch-node-url"].as<std::string>();
   }
   if (options.count("elasticsearch-bulk-replay")) {
      my->_elasticsearch_bulk_replay = options["elasticsearch-bulk-replay"].as<uint32_t>();
   }
   if (options.count("elasticsearch-bulk-sync")) {
      my->_elasticsearch_bulk_sync = options["elasticsearch-bulk-sync"].as<uint32_t>();
   }
   if (options.count("elasticsearch-logs")) {
      my->_elasticsearch_logs = options["elasticsearch-logs"].as<bool>();
   }
   if (options.count("elasticsearch-visitor")) {
      my->_elasticsearch_visitor = options["elasticsearch-visitor"].as<bool>();
   }
}
开发者ID:hanxueming126,项目名称:bitshares-core,代码行数:22,代码来源:elasticsearch_plugin.cpp


示例7: ASSERT

void SQLTransactionBackend::doCleanup()
{
    if (!m_frontend)
        return;
    m_frontend = 0; // Break the reference cycle. See comment about the life-cycle above.

    ASSERT(currentThread() == database()->databaseContext()->databaseThread()->getThreadID());

    releaseOriginLockIfNeeded();

    MutexLocker locker(m_statementMutex);
    m_statementQueue.clear();

    if (m_sqliteTransaction) {
        // In the event we got here because of an interruption or error (i.e. if
        // the transaction is in progress), we should roll it back here. Clearing
        // m_sqliteTransaction invokes SQLiteTransaction's destructor which does
        // just that. We might as well do this unconditionally and free up its
        // resources because we're already terminating.
        m_sqliteTransaction.clear();
    }

    // Release the lock on this database
    if (m_lockAcquired)
        m_database->transactionCoordinator()->releaseLock(this);

    // Do some aggresive clean up here except for m_database.
    //
    // We can't clear m_database here because the frontend may asynchronously
    // invoke SQLTransactionBackend::requestTransitToState(), and that function
    // uses m_database to schedule a state transition. This may occur because
    // the frontend (being in another thread) may already be on the way to
    // requesting our next state before it detects an interruption.
    //
    // There is no harm in letting it finish making the request. It'll set
    // m_requestedState, but we won't execute a transition to that state because
    // we've already shut down the transaction.
    //
    // We also can't clear m_currentStatementBackend and m_transactionError.
    // m_currentStatementBackend may be accessed asynchronously by the
    // frontend's deliverStatementCallback() state. Similarly,
    // m_transactionError may be accessed by deliverTransactionErrorCallback().
    // This occurs if requests for transition to those states have already been
    // registered with the frontend just prior to a clean up request arriving.
    //
    // So instead, let our destructor handle their clean up since this
    // SQLTransactionBackend is guaranteed to not destruct until the frontend
    // is also destructing.

    m_wrapper = 0;
}
开发者ID:fmalita,项目名称:webkit,代码行数:51,代码来源:SQLTransactionBackend.cpp


示例8: Q_ASSERT_X

bool MySqlStorage::createDatabaseTables()
{
        Q_ASSERT_X(database().open(), Q_FUNC_INFO,
                        "Connection to database must be established first");

        bool error = false;
        // create tables:
        for (int i = 0; i < NumberOfTables; ++i)
        {
                if (!database().tables().contains(Tables[i]))
                {
                        QString statement;
                        QTextStream stream(&statement, QIODevice::WriteOnly);

                        stream << "CREATE table  `" << Tables[i] << "` (";
                        const Field* field = Database_Fields[i];
                        while (field->name != QString::null )
                        {
                                stream << " `" << field->name << "` "
                                << field->type;
                                ++field;
                                if ( field->name != QString::null ) stream << ", ";
                        }
                        stream << ");";

                        QSqlQuery query( database() );
                        qDebug() << statement;
                        query.prepare( statement );
                        if ( ! runQuery( query ) )
                        {
                                error = true;
                        }
                }
        }

        error = error || ! setMetaData(CHARM_DATABASE_VERSION_DESCRIPTOR, QString().setNum( CHARM_DATABASE_VERSION) );
        return ! error;
}
开发者ID:hefee,项目名称:Charm,代码行数:38,代码来源:MySqlStorage.cpp


示例9: lock

TKvsDatabase TKvsDatabase::addDatabase(const QString &driver, const QString &connectionName)
{
    QMutexLocker lock(&mutex);

    // Removes it if exists
    if (databaseMap.contains(connectionName))
        removeDatabase(connectionName);

    TKvsDatabaseData data;
    data.connectionName = connectionName;
    data.driver = createDriver(driver);  // creates a driver
    databaseMap.insert(connectionName, data);
    return database(connectionName);
}
开发者ID:ChowZenki,项目名称:treefrog-framework,代码行数:14,代码来源:tkvsdatabase.cpp


示例10: sql

void Database_Login::create ()
{
  SqliteDatabase sql (database ());
  sql.add ("CREATE TABLE IF NOT EXISTS logins ("
           " username text,"
           " address text,"
           " agent text,"
           " fingerprint text,"
           " cookie text,"
           " touch boolean,"
           " timestamp integer"
           ");");
  sql.execute ();
}
开发者ID:bibledit,项目名称:bibledit-windows,代码行数:14,代码来源:login.cpp


示例11: database

//Create new SQLite journal (6/9/13)
bool NewJournalCreator::Create_SQLite_Database(){

    QFile database(sqlite_journal_path + QDir::separator() + sqlite_journal_name);
    QString path=database.fileName();
    path=QDir::toNativeSeparators(path);
    bool proceed=true;

    if(database.exists()){
        QMessageBox j;
        int choice=j.question(this,"RoboJournal","SQLite database <b>" + path + "</b> already exists. "
                              "Do you want to replace it? <br><br><b>Warning:</b> If you choose to replace the "
                              "database, the current contents will be overwritten. This action cannot be undone!",
                              QMessageBox::Yes | QMessageBox::No, QMessageBox::No);

        switch(choice){
        case QMessageBox::Yes:
            proceed=true;
            break;

        case QMessageBox::No:
            proceed=false;
            break;
        }
    }

    bool success;

    if(proceed){
        SQLiteCore sqlite;
        success=sqlite.CreateDB(path);
    }
    else{
        return false;
    }

    QMessageBox m;
    FavoriteCore f;

    if(success){

        m.information(this,"RoboJournal","The new journal was successfully created at <b>" + path + "</b>.");
        f.SQLite_Add_to_DB(path,sqlite_is_favorite);

    }
    else{
        m.critical(this,"RoboJournal","Journal creation attempt failed.");
    }

    return success;
}
开发者ID:pwizard2,项目名称:robojournal,代码行数:51,代码来源:newjournalcreator.cpp


示例12: download

void WebResourceProvider::updateDatabase()
{
	QBuffer indexBuffer;
	indexBuffer.open( QBuffer::ReadWrite );
	download( url() + "/WebResources/Index", &indexBuffer );

	indexBuffer.seek( 0 );

	QDomDocument doc;
	doc.setContent( &indexBuffer );

	importNodeIntoDB( doc.firstChildElement( "webresources" ),
						database()->topLevelNode() );
}
开发者ID:Orpheon,项目名称:lmms,代码行数:14,代码来源:WebResourceProvider.cpp


示例13: TEST

TEST( TestMySQL_Database, TestQExecute )
{
        const ::configFile::Database    &dbb = Core::Config::getInstance("test.ini").database();
        std::string host = dbb.host();
        std::string _database = dbb.database();
        std::string user = dbb.user();
        std::string pass = dbb.password();

	Core::CMySQL_Database database(host.c_str(), _database.c_str(), user.c_str(), pass.c_str());
	EXPECT_NO_FATAL_FAILURE( database.QExecute("DROP TABLE IF EXISTS test_table;"));
	EXPECT_NO_FATAL_FAILURE(database.QExecute("CREATE TABLE test_table(id INT);"));
	EXPECT_NO_FATAL_FAILURE(database.QExecute("DROP TABLE test_table;") );
	EXPECT_THROW(database.QExecute("use table test_table;"), std::exception);
}
开发者ID:gitter-badger,项目名称:osIROSE-new,代码行数:14,代码来源:test_mysql_database.cpp


示例14: ASSERT

void SQLTransaction::postflightAndCommit()
{
    ASSERT(m_lockAcquired);

    // Transaction Step 7 - Peform postflight steps, jumping to the error callback if they fail
    if (m_wrapper && !m_wrapper->performPostflight(this)) {
        m_transactionError = m_wrapper->sqlError();
        if (!m_transactionError)
            m_transactionError = SQLError::create(SQLError::UNKNOWN_ERR, "unknown error occured setting up transaction");
        handleTransactionError(false);
        return;
    }

    // Transacton Step 8+9 - Commit the transaction, jumping to the error callback if that fails
    ASSERT(m_sqliteTransaction);

    m_database->disableAuthorizer();
    m_sqliteTransaction->commit();
    m_database->enableAuthorizer();

    // If the commit failed, the transaction will still be marked as "in progress"
    if (m_sqliteTransaction->inProgress()) {
        if (m_wrapper)
            m_wrapper->handleCommitFailedAfterPostflight(this);
        m_successCallbackWrapper.clear();
        m_transactionError = SQLError::create(SQLError::DATABASE_ERR, "failed to commit the transaction");
        handleTransactionError(false);
        return;
    }

    // Vacuum the database if anything was deleted.
    if (m_database->hadDeletes())
        m_database->incrementalVacuumIfNeeded();

    // The commit was successful. If the transaction modified this database, notify the delegates.
    if (m_modifiedDatabase)
        m_database->transactionClient()->didCommitWriteTransaction(database());

    // Now release our unneeded callbacks, to break reference cycles.
    m_errorCallbackWrapper.clear();

    // Transaction Step 10 - Deliver success callback, if there is one
    if (m_successCallbackWrapper.hasCallback()) {
        m_nextStep = &SQLTransaction::deliverSuccessCallback;
        LOG(StorageAPI, "Scheduling deliverSuccessCallback for transaction %p\n", this);
        m_database->scheduleTransactionCallback(this);
    } else
        cleanupAfterSuccessCallback();
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:49,代码来源:SQLTransaction.cpp


示例15: database

/**
 * @brief QEjdbClientPrivate::load load a Json from database stored in collection
 * identified by collectionName. If nothing found en empty Json is returned.
 *
 * @param collectionName name of collection
 * @param uid Bson uid
 *
 * @return Json Object or empty Json if noting found
 */
QJSValue QEjdbClientPrivate::load(QString collectionName, QJSValue uid)
{
    QEjdbDatabase db = database();
    if (db.containsCollection(collectionName)) {
        QBsonOid oid = QBsonOid(uid.toString());
        if (oid.isValid()) {
            QBsonObject bso = db.load(collectionName, uid.toString());
            if (bso.isEmpty()) {
                return QJSValue(QJSValue::NullValue);
            }
            return QJSValue(convert(bso));
        }
    }
    return QJSValue(QJSValue::NullValue);
}
开发者ID:gitter-badger,项目名称:qtejdb,代码行数:24,代码来源:qejdbclient.cpp


示例16: qDebug

/**
 * @brief QEjdbClientPrivate::save Saves a Json in database. If autoCreateCollection is true
 * colleciton will created.
 *
 * @param collectionName name of collection
 *
 * @param jsValue
 *
 * @return created Json with id parameter
 */
QJSValue QEjdbClientPrivate::save(QString collectionName, const QJSValue &jsValue)
{
    qDebug() << "save value" << jsValue.toVariant() << "in" << collectionName;

    QBsonObject bsonObj = convert(jsValue);

    QEjdbDatabase db = database();
    checkCollection(db, collectionName);
    db.save(collectionName, bsonObj);

    QJSValue resultJs(jsValue);
    resultJs.setProperty("_id", QJSValue(bsonObj.oid().toString()));

    return resultJs;
}
开发者ID:gitter-badger,项目名称:qtejdb,代码行数:25,代码来源:qejdbclient.cpp


示例17: database

void DatabaseManager::slotTables(QString connection, TableProcess process, ErrorProcess error){
    QSqlDatabase database(QSqlDatabase::database(connection));

    if(database.lastError().isValid()){
        error(database.lastError().text());
    }else{
        QStringList tables(database.tables());

        if(database.lastError().isValid()){
            error(database.lastError().text());
        }else{
            process(tables);
        }
    }
}
开发者ID:jasonpaulos,项目名称:MatchMaker,代码行数:15,代码来源:DatabaseManager.cpp


示例18: database

void TagDatabaseInMemoryTest::saveEmpty()
{
	QString filename = "test_tmp_tags_file.txt";

	TagDatabaseInMemory database("tests/resources/tag-types.txt", filename);
	QVERIFY(database.load());

	database.setTags(QList<Tag>());
	QVERIFY(database.save());

	QFile f(filename);
	QVERIFY(f.open(QFile::ReadOnly | QFile::Text));
	QString content = f.readAll();
	QVERIFY(content.isEmpty());
	QVERIFY(f.remove());
}
开发者ID:Flat,项目名称:imgbrd-grabber,代码行数:16,代码来源:tag-database-in-memory-test.cpp


示例19: QueryExecutor

bool SQLiteDocumentDAO::remove(Document::Ptr entity)
{
    if(!entity) {
        return false;
    }

    bool ret = QueryExecutor(database()).remove("document", makeQueryParameters("id", entity->id()));

    if(ret) {
        repository()->publications()->remove(entity->id());

        emit dataChanged();
    }

    return ret;
}
开发者ID:mvaldenegro,项目名称:KResearch,代码行数:16,代码来源:SQLiteDocumentDAO.cpp


示例20: databaseIcons

QPixmap Entry::iconPixmap() const
{
    if (m_data.customIcon.isNull()) {
        return databaseIcons()->iconPixmap(m_data.iconNumber);
    }
    else {
        QPixmap pixmap;
        if (!QPixmapCache::find(m_pixmapCacheKey, &pixmap)) {
            // TODO: check if database() is 0
            pixmap = QPixmap::fromImage(database()->metadata()->customIcon(m_data.customIcon));
            m_pixmapCacheKey = QPixmapCache::insert(pixmap);
        }

        return pixmap;
    }
}
开发者ID:afontenot,项目名称:keepassx,代码行数:16,代码来源:Entry.cpp



注:本文中的database函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ database_error函数代码示例发布时间:2022-05-30
下一篇:
C++ data_type函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap