db.login
Sets user/password for DB driver/database.
db.login [-p] driver=name database=name [user=string] [password=string] [host=string] [port=string] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
db.login driver=sqlite database=$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
grass.script.run_command("db.login", driver="sqlite", database="$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db", user=None, password=None, host=None, port=None, flags=None, overwrite=False, verbose=False, quiet=False, superquiet=False)
Example:
gs.run_command("db.login", driver="sqlite", database="$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db")
Parameters
driver=name [required]
Name of database driver
Allowed values: dbf, ogr, sqlite
Default: sqlite
database=name [required]
Name of database
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
user=string
Username
password=string
Password
host=string
Hostname
Relevant only for pg and mysql driver
port=string
Port
Relevant only for pg and mysql driver
-p
Print connection settings and exit
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
driver : str, required
Name of database driver
Used as: input, dbdriver, name
Allowed values: dbf, ogr, sqlite
Default: sqlite
database : str, required
Name of database
Used as: input, dbname, name
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
user : str, optional
Username
password : str, optional
Password
host : str, optional
Hostname
Relevant only for pg and mysql driver
port : str, optional
Port
Relevant only for pg and mysql driver
flags : str, optional
Allowed values: p
p
Print connection settings and exit
overwrite: bool, optional
Allow output files to overwrite existing files
Default: False
verbose: bool, optional
Verbose module output
Default: False
quiet: bool, optional
Quiet module output
Default: False
superquiet: bool, optional
Very quiet module output
Default: False
DESCRIPTION
db.login sets login parameters such an user name and optionally also a password, a hostname or a port for the connection to the selected database through the DB driver.
NOTE
Options host and port are related to only SQL database backends like PostgreSQL, MySQL or ODBC.
Note that the passwords are stored in a hidden, unencrypted file in the user account, specifically
- in the 'home' directory, i.e.
$HOME/.grass8/dblogin
(Unix-like systems) %APPDATA%\Roaming\GRASS8\dblogin
(MS-Windows)
Only the file owner can access this file.
EXAMPLES
Only username specified (assuming locally accessible PostgreSQL DB without password):
db.login driver=pg database=mydb
Username, password and hostname specified (note that the command lines history will store the password in this way):
db.login driver=pg database=mydb user=bacava password=secret host=db.example.com
Username and empty password specified:
db.login driver=pg database=mydb user=bacava password=""
SEE ALSO
db.connect, db.test, db.tables
AUTHOR
Radim Blazek
Support for hostname and port by Martin Landa, OSGeoREL, Czech Technical
University in Prague, Czech Republic (GRASS 7.1)
SOURCE CODE
Available at: db.login source code
(history)
Latest change: Friday Feb 07 19:16:09 2025 in commit a82a39f