Important: Please read the Qt Code of Conduct -

Use two or more SQLite database at the same time

  • Hello people I have this compiler's ouput

    QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
    QSqlDatabasePrivate::addDatabase: duplicate connection name 'qt_sql_default_connection', old connection removed.

    It's because I use a database:

        db= QSqlDatabase::addDatabase("QSQLITE");

    And then I need to use other one (That depends on an event )

            fallas= QSqlDatabase::addDatabase("QSQLITE");
        QString consulta;
        consulta.append("CREATE TABLE IF NOT EXISTS ");
        consulta.push_back(ui->lineEdit_interseccion->text().remove(" "));
        consulta.push_back("(a TEXT primary key, j TEXT);");
        QSqlQuery crear(fallas);

    And I never close db.

    The problem it's that I will always have to use db, and there is a lot of fallas database and it' will open deppends of an event.

    Is there any way to not have to close db to open other database ? to use both


  • Lifetime Qt Champion

    @Julian You are adding connections with same name:


    This uses default connection name, see
    Just specify connection names as

    db= QSqlDatabase::addDatabase("QSQLITE", "first_connection");
    fallas= QSqlDatabase::addDatabase("QSQLITE", "second_connection");

  • Banned

    This post is deleted!

  • Lifetime Qt Champion

    @vouchermedia I already explained how it should be done above.
    So, what exactly is the problem?
    Is your question related to Qt (you're talking about a website)?
    "If i want to open one db when another data base is open is not possible" - this is not a problem description at all. What exactly does not work? Any errors/warnings? How do you open both databases? Can you show your code?

  • Lifetime Qt Champion

    @jsulm That was spam message.

Log in to reply