I wonder if it is possible to get the user and password for a Oracle Spatial database if they are stored in the Oracle Spatial connection information.

I get layer source, but password and user are empty. I can get host, port, SRID.

  for lyr in QgsProject.instance().mapLayers().values():
  layerName = lyr.name()
  layerName = layerName.upper()
  if layerName == "LOTE_CTM" or layerName.find('LOTE_CTM') != -1 or 
      layerName.find('LOTE CTM') != -1:
      layer = lyr

kvp = layer.source().split(" ")
for kv in kvp:
  if kv.startswith("user"):
    thePassword = kv.split("=")[1][1:-1]
    print (thePassword)
  • 1
    Doesn't a correctly designed system prevent from accessing user password this easily ? – J.R Apr 15 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.