db.connect(1grass)
π db.connect β the bestie that sets up ur database connection π
okay so hi bestie!! welcome to db.connect (that's the manual name, it's from the GRASS User's Manual, cute right) β¨ This one prints and/or sets the general DB connection for the current mapset. That's it. That's the whole gig. But the whole gig is IMPORTANT so pay attention bestie πΈ
β¨ KEYWORDS β¨
database, attribute table, connection settings β yes those are the group chat tags, thank u for asking π
π SYNOPSIS π
db.connect
db.connect --help
db.connect [-pgcd] [driver=name] [database=name] [schema=name]
[group=string] format=name [--help] [--verbose] [--quiet] [--ui]
π FLAGS π
-pβ print the current connection parameters and then dip. exit. done. π-gβ print current connection parameters using shell style and exit. BUT β and this is the tea β it's[deprecated]. like, it's being retired. useformat=shellinstead bestie, fr fr. π
This flag is deprecated and will be removed in a future release. Use format=shell instead.
-cβ check the connection parameters, set them if they're uninitialized, then exit. quiet little caretaker energy. π«Ά-dβ set from default settings and exit. lowkey a glow-up: it overwrites current settings if they're already initialized, so don't be shocked if ur old setup gets replaced β¨--helpβ print usage summary. the classic. π--verboseβ verbose module output, i.e. she's talking more now π£οΈ--quietβ quiet module output, i.e. absolutely no yapping π€«--uiβ force launching the GUI dialog. main character energy, but with buttons. π¦
π PARAMETERS π
driver=nameβ name of the database driver. Options:dbf,mysql,odbc,ogr,pg,sqliteDefault:sqlitedatabase=nameβ name of the database. Default:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.dbschema=nameβ database schema.
Do not use this option if schemas are not supported by the driver/database server. like seriously, don't. it's giving "unsupported" π
group=stringβ default group of database users to which select privilege is granted. yes, a whole group. very generous of u. πformat=name [required]β output format. this one is required bestie, no skipping it. Options:plain,shell,jsonDefault:plainplain: plain text output βοΈshell: shell script style output πjson: JSON (JavaScript Object Notation) π§
π DESCRIPTION π
so like, db.connect lets u set the database connection parameters. then those parameters get picked up as the default values by other modules, so u don't have to type them in every single time like some kind of 1800s peasant. periodt.
the default database backend in GRASS? that's SQLite, and it has been since version 7. iconic. no cap. π
πΈ NOTES πΈ
okay the important stuff, don't scroll past this:
- Values get stored in the mapset's
VARfile. and listen β the connection is NOT tested for validity. she writes it and moves on, she does not check ur homework. π - The
-pflag will display the current connection parameters. - The
-cflag will silently check if the connection parameters have been set, and if they haven't, it'll set them to use GRASS's default values. lowkey a lifesaver in scripts before u attempt to create a new database table. π«Ά - To connect a vector map to a database table, use
v.db.connectorv.db.addtable. different module, different vibe, still ur friend. π
β EXAMPLES β
SQLite (default backend)
Local storage:
db.connect -d
db.connect -p
db.tables -p
The SQLite database file is created automatically when used the first time. it just β¨appearsβ¨.
See SQLite database driver for details.
PostgreSQL (local connection)
Local storage, database tables stored in database "mydb" (may require the use of db.login):
db.connect driver=pg database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
See PostgreSQL database driver for details.
PostgreSQL (network connection)
Network storage, database tables stored in database "mydb" (may require the use of db.login):
db.connect driver=pg database=mydb
db.login user=myname pass=secret host=myserver.com port=6666
db.connect -p
db.tables -p
See PostgreSQL database driver for details.
MySQL (local connection)
Local storage, database tables stored in database "mydb" (may require the use of db.login):
db.connect driver=mysql database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
See MySQL database driver for details.
MySQL (network connection)
Network storage, database tables stored in database "mydb" (may require the use of db.login):
db.connect driver=mysql database=mydb
db.login user=myname pass=secret host=myserver.com
db.connect -p
db.tables -p
See MySQL database driver for details.
ODBC
Network storage, database tables stored in database "mydb" (may require the use of db.login):
db.connect driver=odbc database=mydb
db.login user=myname pass=secret
db.connect -p
db.tables -p
See ODBC database driver for details.
DBF (local, not recommended)
Local storage β and heads up, the dbf/ subdirectory in the mapset must exist, or u gotta create it urself:
db.connect driver=dbf database=β$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/β
db.tables -p
See DBF database driver for details.
also it literally says "not recommended" in the heading soβ¦β¦ read the room bestie π
π¦ SEE ALSO π¦
db.columns,db.copy,db.drivers,db.login,db.tables,v.db.addtable,v.db.connect- GRASS SQL interface
π AUTHORS π
- Main author: Radim Blazek, ITC-Irst, Trento, Italy
- GRASS 7 improvements: Martin Landa, Markus Metz
π SOURCE CODE π
Available at: db.connect source code (history)
Latest change: Monday Nov 03 07:16:48 2025 in commit: c96796774942e46bbababcd652d3986d4e295665
Main index | Database index | Topics index | Keywords index | Graphical index | Full index
and that's the whole page bestie!! this was GRASS 8.5.0, Β© 2003-2026 GRASS Development Team, and it's the GRASS 8.5.0 Reference Manual β so like, u were reading the very same GRASS 8.5.0 / db.connect(1grass) energy the whole time. go set those connection params, u absolute icon πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· 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