It looks like you're new here. If you want to get involved, click one of these buttons!
Hi all
I tried to connect to MySQL database by QSqlDatabase but it failed. Script still running but result not as expected.
I don't know what wrong I did.
q0sql = QSqlDatabase.addDatabase("QMYSQL ")
  #q0sql.driverName = "QMYSQ"
  q0sql.setHostName("myIP")
  q0sql.setDatabaseName("myDB")
  q0sql.setUserName("myuser")
  q0sql.setPassword("mypassword")
  q0sql.setPort(3306)
  print(q0sql.port) #result:-1
  print(q0sql.isValid())# result False
  ok = q0sql.open()
if ok:print("error")
  if ok:print("connected")
  else: print("disconnect")
  q0sql.close()
thank for your helping.
daipv
Comments
Hi dai,
I'm sorry, but I don't have experience with QSqlDatabase myself. First thing is that you should be sure you understand and know how to use the Qt API (i.e. using PyQt or C++). If you know that it's basically working, you can start porting that to KLayout's Qt binding.
Matthias
thanks Matthias
the method proposed in stackflow looks working
@tiboy Very good! Thanks for sharing this and this feedback
Kind regards,
Matthias