QT: driver not loaded, but driver is present - postgresql

EDIT #2
It works, the first time I installed postgres 64bit, while Qt uses MinGW 32 bit.
EDIT
Following the answer linked by zapredelom, I installed postgres 9 and added to PATH the bin and lib directories. To be sure, I also restarted the machine, but nothing changed. QT_DEBUG_PLUGINS=1 gives me no additional debug infos.
I get this error at runtime:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
As the error itself displays, postgres driver is already present. Indeed there's a qsqlpsql.dll and qsqlpsqld.dll under C:\Qt\5.8\mingw53_32\plugins\sqldrivers.
I have not built it and I have no Postgres installation on this machine (I test on my Linux OS and deploy on Windows 8.1 VM), the driver was already present after installing QT.
What's the problem?

The driver does not work because it does not find the dependency (it should be depends on libpq.dll), and when you run it, the plugin can not find the required dll. If you are using windows, just try to check using dependencywalker of the qsqlpsql.dll.
You can directly put your libpq.dll to your application exe folder.

Related

IBM DB2 ODBC DRIVER :: SQL1390C The environment variable DB2INSTANCE is not defined or is invalid

I've followed several guides online and I cannot install IBM DB2 ODBC DRIVER on Windows.
I have downloaded the driver from IBM and installed (which was quite a roller-coaster).
If I follow guide1 or guide2 the result is the same:
SQL1390C The environment variable DB2INSTANCE is not defined or is invalid
Note: this is my C:\Program Files\IBM folder and as you can see there is no bin folder
Not sure if db2oreg1.exe -setup is still mandatory, things might have changed.
Thanks to #MarkBarinstein I found where the problem was.
I've followed this guide How to install IBM db2 ODBC driver in Windows 7 - 64 bit? and I downloaded the wrong package: I downloaded the universal_fixpack instead of the client.
I realized that when I saw the two folders in the Download directory:
So I uninstalled the universal_fixpack and installed the client and the installation was successful.

PostgreSQL driver does not load with PyQt5 [duplicate]

I have some trouble when I want to add a database.
_dataBase = QSqlDatabase::addDatabase("QPSQL");
After calling this method I have an error:
QSqlDatabase: QPSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I include to PATH variable paths to:
PostgreSQL\9.3\bin
PostgreSQL\9.3\lib
PostgreSQL\9.3\include
Also I copy folder sqldrivers to Debug folder. Also tried to copy dlls drom this folder to Debug. Doesn't work either.
I came here googling because I had the same problem in Windows.
In my case to solve the issue I had to install PostgreSQL for Windows 32 bits since my Qt target was MinGW 32 bits.
Additionally, I had to add the PATH to the PostgreSQL bin and lib directories so Qt could find the right .dlls.
#SET PATH=C:\Program Files (x86)\PostgreSQL\9.6\bin\;C:\Program Files (x86)\PostgreSQL\9.6\lib\;%PATH%
The PATH can be set before launching Qt Creator or using the Qt Creator itself via the Build Environment in the Projects pane.
Add the system variable QT_DEBUG_PLUGINS=1 if you want to get full information of why the QPSQL driver has not been loaded.
Probably you will discover that Qt is not able to find it. Copy and paste the output here to know what exactly happens.
Use depends.exe on qsqlpsql.dll and found that this dll need libpq.dll from PostgreSQL\9.3\libfolder. Add libpq.dll to Debug folder and it works:)
Try pip install PyQt5 event if you already installed it using conda or installer. It helped me.
I got same problem with deploying Qt application (windeployqt didn't help). I had to copy more .dlls (libcrypto-1_1-x64.dll, libiconv-2.dll, libintl-8.dll, libpq.dll, libssl-1_1-x64.dll, libwinpthread-1.dll) from postgreSQL bin path (c:\Program Files\PostgreSQL\12\bin) next to .exe file (according to dependency walker).

postgres odbc connection fails

I am trying to set up a new postgres odbc connection for an application.
This is done on 32-bit Windows 7 system. I installed latest postgresql 9.6 & psqlodbc 0905, and there were no errors. When I add the odbc connection string and test connectivity with postgres login, it fails with the following error:
Test connection failed because of an error in initialized provider.
Specified driver could not be loaded due to system error 182:
(PostgreSQL UNICODE, C:\Program
Files\psqlODBC\0905\bin\psqlodbc35w.dll)
Here's the connection string:
Driver={PostgreSQL
UNICODE};Server=127.0.0.1;Port=5432;Database=postgres;
Uid=postgres;Pwd=postgres;
I then installed Visual C++ redistributable packager versions 2008 and 2010 later. Rebooted the box. Still same issue.
Postgres + odbc + other installs were complete and without any errors.
This is getting too frustrating.
Please.. any ideas on how to fix this will be helpful.?!
Update: I have tested the following:
1. Installed older postgres & psdqlodbc version
2. Added psqlodbc path to PATH env variable at the start
3. Uninstalled standalone psqlodbc installs, and installed Stackbuilder from postgresql package to download and install psqlodbc component.
All of these have not not been any useful.
Final Update: I was able to fix this by using psqlodbc_09_03_0400. For whatever reason, other versions kept throwing error.
Apparently, according to the Microsoft index of error codes, error 182 means ERROR_INVALID_ORDINAL, which with the help of this answer I believe means that the postgresql ODBC driver is loading another DLL and trying to call a function within it that does not exist.
The most likely cause for this would be that the system is loading a wrong version of a DLL on which psqlodbc depends. In fact I found this thread where someone else was having the same issue (although back in 2005).
This could happen if you had installed some other package containing one of the DLLs that psqlodbc relies on, or maybe even another version of psqlodbc.
Try changing the windows search path to put the directory containing the psqlodbc drivers at the front to confirm if this is the case. If that works you might want to try to narrow the problem down until you can find exactly what DLL is conflicting, and if possible remove it.
It is also possible that there is some packaging issue with the psqlodbc package you are using - if that is the case you could try uninstalling that one and installing an earlier version.
Final Update: I was able to fix this by using psqlodbc_09_03_0400. For whatever reason, other versions kept throwing error.

pgAdmin 4 not starting on Windows 10 64bit

After a fresh install of postgres 9.6.0.1 for Windows 10 64bit I am not able to get pgAdmin 4 starting.
First it throws an fatal error message:
After OK, that message appears:
Is there anything wrong? because after OK - the program won't start.
What can I do to get pgadmin 4 running? What should I enter in Python Path and what in Application Path?
I have found now the problem, it was the Java installation on which pgadmin 4 depend heavily.
In Windows when installing Java 8 (Java SE in this case) you do not have to use JAVA_HOME and JAVA_JRE anylonger and you can install java with default path settings (with the version number)
So I installed JAVA SDK 8 32 and 64bit and pgadmin start up normally.
The PATH variable includes only C:\ProgramData\Oracle\Java\javapath, thats all and let you use allways the latest version of java you installed.
In my case, I installed pgAdmin 4 v4.25 (released Aug. 20, 2020) . It solved my issue .
I had the same problem. I think, the installation of Visual C++ 2013 Redistributable is the source.
I fixed it uninstalling pgAdmin 4 and installing it again.
It tried to install Visual C++ 2013 Redistributable again, but it was already installed and now it works.
Hope this helps.
Try to install pgamin 4.5.1, it works for me (w10 x64) pgadmin 4.1.5
After struggling for weeks with this problem I found a solution. In my case I have Anaconda installed and maybe it affects PgAdmin in some way, I don't know. In order to start PgAdmin I followed these steps:
Open cmd and move to C:\Program Files\PostgreSQL\11\pgAdmin 4\web
Run pgAdmin4.py with your Python distribution. I had to install several libraries.
In my case, an error appeared, I needed to change Line #32 of C:\Program Files\PostgreSQL\11\pgAdmin 4\web\pgadmin\browser\__init__.py. More precisely:
from flask_security.views import _security, _commit, default_render_json, _ctx to
from flask_security.views import _security, _commit, _render_json, _ctx
Last, I needed to edited line socket module from Python libraries, gethostbyaddr(name) found non-ASCII symbols in the host name of my computer, I don't have any of them :S. Well, I changed line #687
hostname, aliases, ipaddrs = gethostbyaddr(name) to
hostname, aliases, ipaddrs = gethostbyaddr("")
After all of these steps I run pgAdmin4.py again and it worked.
Hope it helps.
For me there was no way to make it work (pgAdmin4 Version 4.21 that comes with Postgres 11.8 on Windows 10 x64). I really tried every possible solution.
So I gave up and found pgAdmin3 Redux: https://tokavuh.com/pgAdmin3Redux/ that supports Postgres 11, too.
You will probably have problems starting it, because of missing dll's from some Visual C++ Redistributable version I could not find out, but fortunately you will find these missing dll's on https://www.dll-files.com, just search them there as errors pops up.

Installing MongoDB in Windows xp 64-bit

I am trying to install mongoDB in Windows xp 64-bit, while executing mongod.exe in terminal it throws "The procedure entry point InitailizeSRWLock could not be located in the dynamic link library KERNEL32.dll" error, how to resolve this error ?
You'll need either the 32bit or 64bit "legacy" build of MongoDb for older operating systems. The error you're seeing indicates you've tried to execute a build for newer versions of Windows. The function InitializeSRWLock (reference) is only available on Windows 7/2008+.
At first ,make sure the mongodb you downloaded is just the suitable one for you system.
Secondly ,it seems that you system needs the KERNEL32.dll.You'd better download the KERNEL32.dll manually and put it into your c:\Windows\System\ directory.