<html><body><div><div><span>Hi,</span></div><br><div><span>Actually, after I turned off the computer, I saw the fileName() method in documentation.</span></div><br><div><span>I tried it and I realised that both my password and project name needed percent encoding some characters.</span></div><br><div><span>So I have parsed my uri string with urllob.parse.quote to make it work correctly.</span></div><br><div><span>Not sure if there's a more convenient way to do it.</span></div><br><div><span>Thanks for the help German.</span></div><br><div><span>Alex Neto</span></div></div><br><div><div>On Sat May 13, 2023, 02:23 AM GMT, <a href="mailto:carrillo.german@gmail.com">Germán Carrillo</a> wrote:<br></div><blockquote style="margin:0 0 0 4pt;padding-left:4pt;border-left:1px solid #CCC"><div><div dir="ltr"><div dir="ltr">Hi,<div><br></div><div>what do you get if you run the following line on your QGIS Python console in a QGIS session where your project (the one stored in PG) is loaded?</div><div><br></div><div>QgsProject.instance().fileName()<br></div></div><div><br></div><div>Regards, </div><div><br></div><div>Germán</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El vie, 12 may 2023 a las 19:22, Alexandre Neto via QGIS-Developer (<<a href="mailto:qgis-developer@lists.osgeo.org">qgis-developer@lists.osgeo.org</a>>) escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>I am trying to read a project that is stored in a postgreSQL/PostGIS database, but I am struggling with getting it correctly. I am using the following code<br></div><div><br></div><div>project = QgsProject.instance()<br>uri = 'postgresql://my_user:my_pass@localhost:5432?sslmode=disable&dbname=my_database&schema=my_schema&project=my_project_name'<br>project.read(uri)</div><div><br></div><div>The last command always return false, and no project is loaded<br></div><div><br></div><div>The documentation of QgsProject.read() only mentions filenames, not uri, but this answer seems to propose this uri format that would work:</div><div><br></div><div><a href="https://gis.stackexchange.com/a/354615/6191" target="_blank" rel="noopener noreferrer">https://gis.stackexchange.com/a/354615/6191</a></div><div><br></div><div>Any suggestions on how to solve or debug this? I get no error messages from the read method.</div><div><br></div><div>Thanks,</div><div><br></div><div>Aleandre Neto<br></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" rel="noopener noreferrer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank" rel="noopener noreferrer">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>-----------<br></div><div> |\__ <br>(:>__)(<br> |/ <br>Soluciones Geoinformáticas Libres <br><a href="http://geotux.tuxfamily.org/" target="_blank" rel="noopener noreferrer">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2" target="_blank" rel="noopener noreferrer">https://twitter.com/GeoTux2</a></div><div><br></div><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div></div></div></div></div></div><div><div><br></div><div><a href="http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo" target="_blank" rel="noopener noreferrer"><img src="http://gis.stackexchange.com/users/flair/4972.png"></a></div></div></div></div></div></div></div></div>
</div></blockquote></div></body></html>