Joshua Arnott wrote:

> I've had a look at the database functions in 
> the grass.script.db python library, but haven't had any luck getting the 
> db_select function to work. In the default install, the function didn't 
> even exist in db.py. I've added it, based on the current source, but all 
> I get out is:
> 
>  >>> grass.script.db.db_select('Population_Density','select * from 
> Population_Density')
> Sorry, <output> is not a valid parameter
> []

That parameter was added in 7.0. The 6.x version of db.select always
writes to stdout.

You can just run db.select using grass.script.pipe_command(), e.g.:

        import grass.script as grass

        ps = grass.pipe_command(
            'db.select',
            quiet = True,
            flags = 'c',
            table = table,
            sql = sql)

        for line in ps.stdout:
            fields = line.strip().split('|')
            ...

        ps.wait()

-- 
Glynn Clements <[email protected]>
_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to