[Qgis-community-team] Issue regarding spatial data reading in Python API

Gopal Mantri gopal.mantri at tcs.com
Tue Aug 13 05:22:27 PDT 2019


Hi Tim,
We cannot provide the exact code due to organizational policies. But the logic looks somewhat like this.
We are facing issue in selecting the spatial columns of the spatial table.
Also please provide the qgis-developer mailing list id.

from qgis.PyQt.QtSql import QSqlDatabase, QSqlQuery

if not QSqlDatabase.isDriverAvailable('QOCISPATIAL'):
    print ('Oracle driver not available')

db = QSqlDatabase.addDatabase("QOCISPATIAL")

db.setDatabaseName('Hostname' + '/' + 'database')

db.setDatabaseName(‘hostname’+ ':' + str('port') + '/' + 'database')

db.setUserName(‘username)
db.setPassword('password')

if not db.open():
    print ('Could not open connection.')

q = QSqlQuery(db)
q.exec_('SELECT * FROM tablename’)
while(q.next()):
    print(str(q.value(0)))

db.close()

Thanks & Regards,
Gopal Krishna Mantri
Phone:- 020-67259194
[TCS Sig New]

From: Tim Sutton [mailto:tim at kartoza.com]
Sent: Tuesday, August 13, 2019 5:10 PM
To: Gopal Mantri <gopal.mantri at tcs.com>
Cc: qgis-community-team at lists.osgeo.org; Anupriya Mall <anupriya.mall at tcs.com>
Subject: Re: [Qgis-community-team] Issue regarding spatial data reading in Python API

"External email. Open with Caution"
Can you direct your query to the qgis-developer mailing list rather please - and do supply specific code examples of what you have already tried. If you ask generic questions you will likely get generic answers.

Also make sure to consult the cookbook before asking your question:

https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/

Regards

Tim


On 13 Aug 2019, at 07:16, Gopal Mantri <gopal.mantri at tcs.com<mailto:gopal.mantri at tcs.com>> wrote:

Hello team,
I want to create maps through python API in QGIS with Oracle database containing spatial data.
I am able to connect the database. But, I am facing issue in reading the spatial points.
Can I get help in how to read spatial data and create map through Python API?

Thanks & Regards,
Gopal Krishna Mantri
Phone:- 020-67259194
<image001.jpg>

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you

_______________________________________________
Qgis-community-team mailing list for organizing community resources such as documentation, translation etc..
Qgis-community-team at lists.osgeo.org<mailto:Qgis-community-team at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/qgis-community-team

—


[cid:image002.jpg at 01D551FF.AF04DEE0]





Tim Sutton

Co-founder: Kartoza
Ex Project chair: QGIS.org<http://QGIS.org>

Visit http://kartoza.com<http://kartoza.com/> to find out about open source:

Desktop GIS programming services
Geospatial web development
GIS Training
Consulting Services

Skype: timlinux
IRC: timlinux on #qgis at freenode.net<http://freenode.net>

I'd love to connect. Here's my calendar link<https://calendly.com/timlinux> to make finding time easy.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-community-team/attachments/20190813/7562ff6f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 9219 bytes
Desc: image001.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-community-team/attachments/20190813/7562ff6f/attachment-0002.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.jpg
Type: image/jpeg
Size: 6122 bytes
Desc: image002.jpg
URL: <http://lists.osgeo.org/pipermail/qgis-community-team/attachments/20190813/7562ff6f/attachment-0003.jpg>


More information about the Qgis-community-team mailing list