I am developing a plugin that connects to a spatialite DB , do some queries and outputs the results to a spatialite table. I had tried with the below code to connect to the DB and print the queried result to the console as first step.

from pyspatialite import dbapi2 as db
conn = db.connect('/home/farook/DB/cities.sqlite')
cur = conn.cursor()
sql = 'select * from test_pt'
rs = cur.execute(sql)
print(rs)

I could not see anything printed for the given query. Please tell me where i am wrong.

up vote 4 down vote accepted
cur.execute(sql)
rows = cur.fetchall()
for row in rows:
     print row

or for one record:

row = cur.fetchone()
print row

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.