db.select(1)
πΎ db.select β the GRASS GIS bestie manual πΎ
ok so you opened the manual for db.select, which lives in the GRASS GIS User's Manual and is page db.select(1). she's a database girlie. let's get into it π«Ά
β¨ NAME β¨
db.select β selects data from an attribute table. she performs SQL query statement(s), plural, yes ma'am π
π·οΈ KEYWORDS π·οΈ
database, attribute table, SQL
πΈ SYNOPSIS πΈ
db.select
db.select --help
db.select [-cdvt] [sql=sql_query] [input=name] [table=name]
[driver=name] [database=name] [separator=character]
[vertical_separator=character] [null_value=string] [output=name]
[--overwrite] [--help] [--verbose] [--quiet] [--ui]
π Flags π
-cβ do NOT include column names in the output. just the vibes, no labels.-dβ describe the query only, don't actually run it. window shopping fr.-vβ vertical output instead of horizontal. she's standing up now π-tβ only test the query, do not execute. a vibe check, not a full send.--overwriteβ allow output files to overwrite files that already exist. yes she will eat your old file, be careful bestie π--helpβ print usage summary. your lil cheat sheet β¨--verboseβ verbose module output. she will NOT stop talking and honestly? iconic.--quietβ quiet module output. she's giving mystery, she's giving silence π€«--uiβ force launching the GUI dialog. for the girlies who like buttons π±οΈ
π¦ Parameters π¦
sql=sql_queryβ an SQL SELECT statement. Example:select * from towns where population > 10000input=nameβ name of file containing SQL select statement(s). use'-'for standard input.table=nameβ name of table to query.driver=nameβ name of database driver. Options:dbf,mesql,mysql,odbc,ogr,pg,sqliteDefault:sqlitedatabase=nameβ name of database. Default:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.dbseparator=characterβ field separator. Special characters:pipe,comma,space,tab,newlineDefault:pipevertical_separator=characterβ vertical record separator (this one REQUIRES the-vflag, no-vno separator, that's the rule π). Special characters:pipe,comma,space,tab,newlinenull_value=stringβ string representing a NULL value.output=nameβ name for output file (if omitted or"-"it goes to stdout).
π DESCRIPTION π
db.select prints the result of a selection from the database, based on an SQL statement read from an input file or from standard input, and sends it to standard output. no cap.
ok but the rule, and it is a strict rule: each individual query has to be written on one single line, and different queries have to be written on separate lines. one line per query, bestie, don't fight it π«Ά
π NOTE π
if the parameters for the database connection are already set with db.connect, they get taken as default values and you do not need to specify them every single time like a tryhard. the output will be displayed to standard output, or you can direct it to a file with the output option. queen behavior β¨
π EXAMPLES π
Basic usage
db.select sql="select * from roads"
or
echo "select * from roads" | db.select input=-
or
db.select input=file.sql
or
cat file.sql | db.select input=-
Select all from table roads:
db.select -c driver=odbc database=mydb table=hospitals \
input=file.sql output=result.csv
Select some string attribute, exclude others:
db.select sql="SELECT * FROM archsites WHERE str1 <> βNo Nameβ"
Select some string attribute with ZERO length:
db.select sql="SELECT * FROM archsites WHERE str1 IS NULL"
Select coordinates from a PostGIS table:
db.select sql="SELECT x(geo),y(geo) FROM localizzazione"
Execute multiple SQL statements
cat file.sql
SELECT * FROM busstopsall WHERE cat = 1
SELECT cat FROM busstopsall WHERE cat > 4 AND cat < 8
db.select input=file.sql
Count number of cases falling into same position
when multiple observations have the same spatial coordinates, they can still be counted (and if you need them, the coordinates can be uploaded to the attribute table by v.to.db):
db.select sql="SELECT long,lat,site_id,department,obs,COUNT(long) as count_cases \
FROM diseases GROUP BY long,lat"
π SEE ALSO π
db.connect, db.describe, db.drivers, db.droptable, db.execute, db.login, db.tables
the GRASS SQL interface
π AUTHORS π
- Original author unknown (probably CERL)
- Modifications by Radim Blazek, ITC-Irst, Trento, Italy
- Support for multiple statements by Martin Landa, Czech Technical University in Prague
π§ SOURCE CODE π§
Available at: db.select source code (history)
Accessed: Saturday Jan 17 05:40:34 2026
Main index | Database index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's the whole page bestie, we ate and left absolutely no crumbs π β¨
ok so before you go: this whole thing is GRASS 8.4.2 β that's the version, and it was the db.select(1) page from that reference manual, accessed Saturday Jan 17 05:40:34 2026. the manual itself is Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual. go query something cute π¦π
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms