3

I have python code that I am executing but it gives me following error:

<sqlite3.Cursor object at 0x7f3c7666dc00>

when I execute the cur.execute(statement). the code that is below the cur.execute is not read and nothing gets written. here is part of the code i am using

statement = 'select "index",path,id from %s' %(table,) + " WHERE done IS NULL AND job = '%s';" %(job,)
cur.execute(statement)
for row in cur:
    print row
    pszFilename = row[1]
    name = os.path.basename(pszFilename)
    foo = int(name[2:4])
    if foo%2 == 0:
        meridian = foo + 1
    else: meridian = foo     
    print 'meridian: ',meridian
  • 4
    Seems not a GIS question, perhaps you should consider moving it to StackOverflow? – unicoletti Dec 20 '12 at 13:08
  • Try printing statement to make sure it really looks like you expect it to, and then try that in the sqlite shell as suggested by kyle. – BradHards Jan 20 '13 at 0:44
1

I would guess it is working, but your sql returns no rows. Try hooking up to the database with the sqlite3 shell and check your sql. I've found that sqlite is pretty quiet with incorrect sql (tables don't exist, etc). Another observation, although it's a guess, since you posted on the GIS forum and use the GDAL like variable name pszFilename, you can use the ogr sqlite driver to read from a sqlite database. Fetch a layer, set an attribute filter on the layer and iterate through the features.

Your Answer

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

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