db.connect(1)

πŸ’… db.connect(1) β€” it's giving GRASS GIS User's Manual energy

okay bestie, welcome to db.connect, the GRASS GIS era of your life ✨ it prints and/or sets the general DB connection for the current mapset, which like… is the whole vibe. 🫢

✨ NAME ✨

db.connect β€” prints/sets general DB connection for current mapset. periodt.


🏷️ KEYWORDS 🏷️

database, attribute table, connection settings 🌸


πŸ¦‹ SYNOPSIS πŸ¦‹

db.connect
db.connect --help
db.connect [-pgcd]  [driver=name]   [database=name]   [schema=name]
[group=string]   [--help]  [--verbose]  [--quiet]  [--ui]

πŸŽ€ Flags πŸŽ€

  • -p β€” Print current connection parameters and exit. also, Substitute variables in database settings ✨
  • -g β€” Print current connection parameters using shell style and exit πŸ”₯
  • -c β€” Check connection parameters, set if uninitialized, and exit πŸ‘‘
  • -d β€” Set from default settings and exit. it will Overwrite current settings if already initialized, no cap
  • --help β€” Print usage summary πŸ™ˆ
  • --verbose β€” Verbose module output
  • --quiet β€” Quiet module output 🀫
  • --ui β€” Force launching GUI dialog πŸ’…

🌈 Parameters 🌈

  • driver=name β€” Name of database driver
    • Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
    • Default: sqlite
  • database=name β€” Name of database
    • Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
  • schema=name β€” Database schema
    • Do not use this option if schemas are not supported by driver/database server 🚫
  • group=string β€” Default group of database users to which select privilege is granted

πŸ’– DESCRIPTION πŸ’–

db.connect lets you set database connection parameters. once you do that, modules take those parameters as their default values, so you literally don't have to type them in every single time. main character energy for your workflow, fr fr. ✨

the default database backend in GRASS GIS is SQLite (since version 7). iconic. πŸŽ€


πŸ“ NOTES πŸ“

values are stored in the mapset's VAR file; the connection is not tested for validity. so like, it will not check you, bestie πŸ’€

the -p flag will display the current connection parameters. πŸ¦‹

the -c flag will silently check if the connection parameters have been set, and if not, it will set them to use GRASS's default values. (useful in scripts before you attempt to create a new database table 🌸)

to connect a vector map to a database table, use v.db.connect or v.db.addtable. iykyk 🫢


🌟 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. ✨

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.

bestie. it literally says "not recommended" in the name. just so you know. πŸ™ˆ

Local storage (the dbf/ subdirectory in the mapset must exist or must be created by the user):

db.connect driver=dbf database=’$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/’
db.tables -p

See DBF database driver for details.


πŸ‘€ 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)

Accessed: Saturday Jan 17 05:40:33 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 πŸ’œ this was GRASS 8.4.2, page db.connect(1), last touched Saturday Jan 17 05:40:33 2026 β€” go set that connection, slay, and remember: values go in the mapset's VAR file and nobody's checking them for validity πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from