<div dir="ltr">Hi mate,<div><br></div><div>If you still need further details of database uri, you may refer to the skeleton code below. </div><div><br></div><div>obj_vl = QgsVectorLayer(in_fc,"new lyr","ogr")<br>datapr=obj_vl.dataProvider()<br>lyrUri=None<br>if isinstance(obj_vl, QgsVectorLayer):<br> lyrUri = QgsDataSourceUri(obj_vl.dataProvider().dataSourceUri())<br> if lyrUri.database() == "shapefileName" or \<br> os.path.splitext(os.path.basename(lyrUri.uri().split('|')[0]))[0] == "shapefileName":<br> pass<br><br>connParams = dict()<br>if obj_vl.providerType() == 'postgres':<br> connParams['host'] = lyrUri.host()<br> connParams['port'] = lyrUri.port()<br> connParams['user'] = lyrUri.username()<br> connParams['password'] = lyrUri.password()<br>elif obj_vl.providerType() == 'spatialite':<br> connParams['dbPath'] = lyrUri.database()<br>elif obj_vl.providerType() == 'ogr':<br> connParams['dbPath'] = lyrUri.database()<br></div><div><br></div><div>-Prem</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Apr 29, 2021 at 7:01 PM Bo Victor Thomsen <<a href="mailto:bo.victor.thomsen@gmail.com">bo.victor.thomsen@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Thanks Alessandro :-) <br>
</p>
<p>(I need some new reading glasses, or maybe a new brain. When you
read the <i>Properties</i> -> <i>Information</i> tab for the
layer, the needed information is shown in the tab with the prefix
<i><b>Source</b>: </i>! It shouldn't be that hard for me to
guess!!) <br>
</p>
<pre cols="72">Med venlig hilsen / Kind regards
Bo Victor Thomsen</pre>
<div>Den 29-04-2021 kl. 14:32 skrev
Alessandro Pasotti:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div>Hi Bo,</div>
<div><br>
</div>
<div>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">iface.activeLayer().source() should give you what you want.</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">
</p>
<p style="margin:0px;text-indent:0px;white-space:pre-wrap">
</p>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Thu, Apr 29, 2021 at 2:21
PM Bo Victor Thomsen <<a href="mailto:bo.victor.thomsen@gmail.com" target="_blank">bo.victor.thomsen@gmail.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi
list -<br>
<br>
I have a (probably totally obvious, stupid) Pyhton question:<br>
<br>
I need the datasource URI string of a maplayer chosen by the
user.<br>
<br>
I have found the QgsMapLayer chosen by the user. And the
QgsVectorLayer <br>
associated with the Maplayer.<br>
<br>
How do I find the datasource string associated with the
QgsVectorLayer?<br>
<br>
There is oodles of QGIS information about generating a vector
layer from <br>
a specific datasource. I need the opposite to generate a
virtual layer <br>
in Python using a join between the chosen layer with a another
<br>
predefined layer (which I have the datasource string for).<br>
<br>
-- <br>
<br>
Med venlig hilsen / Kind regards<br>
<br>
Bo Victor Thomsen<br>
<br>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote>
</div>
<br clear="all">
<br>
-- <br>
<div dir="ltr">
<div dir="ltr">
<div>Alessandro Pasotti</div>
<div>QCooperative: <a href="https://www.qcooperative.net" target="_blank">www.qcooperative.net</a><br>
</div>
ItOpen: <a href="http://www.itopen.it" target="_blank">www.itopen.it</a></div>
</div>
</blockquote>
</div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>