0

So, its like these, I made a cluster database for PostgreSQL, with the help of this answer starting postgresql and pgadmin in windows without installation. So the Database is working I can see on PgAdmin, but when I tried to connect it through PyQt5 I got these error:

Driver not loaded Driver not loaded

I tried QPSQL driver and QPSQL7 driver but still the same error so I went to see all available drivers i got:

QSQLITE, QMYSQL, QMYSQL3, QODBC, QODBC3, QPSQL, QPSQL7

when I tried to read the driver error I got:

Driver not loaded

and when I tried to read the database error I got:

Driver not loaded

But when I try to Use psycopg2 lib it works, perfectly. So that got me thinking maybe I installed my PyQt5 wrongly, but I used pip to install all libs. Does anyone know why is it happening and can anyone help me?

def creatConn():
    _db = QSqlDatabase.addDatabase('QPSQL')
    _db.setDatabaseName('database')
    _db.setUserName('username')
    _db.setPassword('password')
    _db.setPort(int('port')
    _db.setHostName('host')
    if _db.open():
       return _db    
    else:
       return False
Fe3back
  • 924
  • 7
  • 15
  • Can you post your code? Otherwise it will be impossible to help. – Isma Aug 16 '18 at 09:35
  • Done, but I was doing some test in my other OS and on MacOS it works and on linux but on windows doesn't work. – Fe3back Aug 16 '18 at 09:52
  • now im about to reinstall the whole python, see if its going to work. maybe there was something bad on my installation. – Fe3back Aug 16 '18 at 09:56
  • can you please tell me the output of following code in the same program? it tells which drivers are correctly installed, `dbliste = QtSql.QSqlDatabase.drivers() print(dbliste)` – khaldi Aug 16 '18 at 10:05
  • i get this: QSQLITE, QMYSQL, QMYSQL3, QODBC, QODBC3, QPSQL, QPSQL7 – Fe3back Aug 16 '18 at 10:40

1 Answers1

-2

im done reinstalling python and as how I was predicting, it works. I don't know what was wrong because I reinstalled, PyQt5 the same way I installed the first time. pip install PyQt5. Thank you for all the help.

Fe3back
  • 924
  • 7
  • 15