Brewtarget / brewtarget

Main brewtarget source code repository.
GNU General Public License v3.0
315 stars 135 forks source link

PostgreSQL Driver not loaded #757

Open jeroen79 opened 1 year ago

jeroen79 commented 1 year ago

Hi,

I was trying to use postgres instead of sqlite, but i get a popup Driver nog loaded, and also see the following error in die console dialog:

[19:15:16.684] (4fw) WARNING : QSqlDatabase: QPSQL driver not loaded [:0] [19:15:16.686] (4fw) WARNING : QSqlDatabase: available drivers: QIBASE QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 [:0]

Is there any additional action needed to load the driver? I do see that the driver dll (qsqlpsql.dll) exists in the sqldrivers folder.

Thx, Jeroen

matty0ung commented 1 year ago

Sorry to hear you're having problems.

It's not the most helpful error message is it? :smiling_face_with_tear: I have vague a feeling that it might be something to do with there being two layers through which the DB is access and the top one (internal to the Qt framework) is loaded but the bottom one (the PosgreSQL native driver) is not. But, I could be completely wrong about that!

@mikfire is our resident PostgreSQL guru, so hopefully this might be one of the things he has already encountered.

If not, it would be good to get the whole debug log prior to this warning message. (Shout if you need help on how to do that.) It might have some clues, or there might be some more diagnostics we can add in the next build.

jeroen79 commented 1 year ago

Here is also the entire log:

log.txt

This install is on windows, but i did also try it on linux with the same result

matty0ung commented 1 year ago

Thanks. Two things to try:

  1. You need to make sure a copy of libpq.dll is placed in the same folder as the Brewtarget executable (see https://doc.qt.io/qt-6/sql-driver.html#qpsql-for-postgresql-version-7-3-and-above). You should be able to find libpq.dll somewhere in your PostgreSQL install as it's what provides the public API into PostgreSQL (see https://www.postgresql.org/docs/current/libpq.html). I believe the qsqlpsql.dll library you already found then translates between PostgreSQL public API and Qt internal API.
  2. If that doesn't work, try switching the Brewtarget log mode to debug. That should produce a much more verbose log. The "official" way to do this is to switch back to SQLite, start Brewtarget and in "Tools > Options > Logging" set the logging level to "Detailed (for debugging)". Alternatively, if you want to take a shortcut, edit your C:/Users/*/AppData/Local/brewtarget/brewtargetPersistentSettings.conf file and add LoggingLevel=DEBUG on a line by itself in the [General] section.