Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Two database connections with different drivers at the same time?

[SOLVED] Two database connections with different drivers at the same time?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    goofacz
    wrote on last edited by
    #1

    Hello!

    I try to establish two database connections, one with PostgreSQL and second with SQLite. I start with code:

    @QSqlDatabase mainDatabase = QSqlDatabase::addDatabase("QPSQL", "MainDatabase");
    QSqlDatabase mapDatabase = QSqlDatabase::addDatabase("QSQLITE", "MapDatabase");@

    then I setup and test connection with PostgreSQL - everything its fine so far. When I try to open SQLite databse with code:

    @mapDatabase.setDatabaseName("db_name");
    if (!this->mapTilesDatabase.open())
    {
    // error handling
    }@

    I recieve error: Driver not loaded.

    Is it possible to use two different database divers simultaneously at all?

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      Welcome to DevNet!

      Using different database drivers works without problems. Is the sqlite driver really available? What the output of

      @
      qDebug() << QSqlDatabase::drivers();
      @

      I'm not sure if that's of importance, but in your second snippet you set the database name on mapDatabase but try to open mapTilesDatabase.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • G Offline
        G Offline
        goofacz
        wrote on last edited by
        #3

        @Volker thank you for response. Reason of this problem was not Qt-related. I somehow removed qsqlite plugin from my system. After reinstalling Qt everything works fine.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved