1db.connect(1) Grass User's Manual db.connect(1)
2
3
4
6 db.connect - Prints/sets general DB connection for current mapset.
7
9 database, attribute table, connection settings
10
12 db.connect
13 db.connect --help
14 db.connect [-pgcd] [driver=name] [database=name] [schema=name]
15 [group=string] [--help] [--verbose] [--quiet] [--ui]
16
17 Flags:
18 -p
19 Print current connection parameters and exit
20 Substitute variables in database settings
21
22 -g
23 Print current connection parameters using shell style and exit
24
25 -c
26 Check connection parameters, set if uninitialized, and exit
27
28 -d
29 Set from default settings and exit
30 Overwrite current settings if already initialized
31
32 --help
33 Print usage summary
34
35 --verbose
36 Verbose module output
37
38 --quiet
39 Quiet module output
40
41 --ui
42 Force launching GUI dialog
43
44 Parameters:
45 driver=name
46 Name of database driver
47 Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
48 Default: sqlite
49
50 database=name
51 Name of database
52 Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
53
54 schema=name
55 Database schema
56 Do not use this option if schemas are not supported by driver/data‐
57 base server
58
59 group=string
60 Default group of database users to which select privilege is
61 granted
62
64 db.connect allows the user to set database connection parameters.
65 These parameters are then taken as default values by modules so that
66 the user does not need to enter the parameters each time.
67
68 The default database backend in GRASS GIS 7 is SQLite.
69
71 Values are stored in the mapset’s VAR file; the connection is not
72 tested for validity.
73
74 The -p flag will display the current connection parameters.
75
76 The -c flag will silently check if the connection parameters have been
77 set, and if not will set them to use GRASS’s default values. (useful
78 in scripts before you attempt to create a new database table)
79
80 To connect a vector map to a database table, use v.db.connect or
81 v.db.addtable.
82
84 SQLite (default backend)
85 Local storage:
86 db.connect -d
87 db.connect -p
88 db.tables -p
89
90 The SQLite database file is created automatically when used the first
91 time.
92
93 See SQLite database driver for details.
94
95 PostgreSQL (local connection)
96 Local storage, database tables stored in database "mydb" (may require
97 the use of db.login):
98 db.connect driver=pg database=mydb
99 db.login user=myname pass=secret
100 db.connect -p
101 db.tables -p
102
103 See PostgreSQL database driver for details.
104
105 PostgreSQL (network connection)
106 Network storage, database tables stored in database "mydb" (may require
107 the use of db.login):
108 db.connect driver=pg database=mydb
109 db.login user=myname pass=secret host=myserver.com port=6666
110 db.connect -p
111 db.tables -p
112
113 See PostgreSQL database driver for details.
114
115 MySQL (local connection)
116 Local storage, database tables stored in database "mydb" (may require
117 the use of db.login):
118 db.connect driver=mysql database=mydb
119 db.login user=myname pass=secret
120 db.connect -p
121 db.tables -p
122
123 See MySQL database driver for details.
124
125 MySQL (network connection)
126 Network storage, database tables stored in database "mydb" (may require
127 the use of db.login):
128 db.connect driver=mysql database=mydb
129 db.login user=myname pass=secret host=myserver.com
130 db.connect -p
131 db.tables -p
132
133 See MySQL database driver for details.
134
135 ODBC
136 Network storage, database tables stored in database "mydb" (may require
137 the use of db.login):
138 db.connect driver=odbc database=mydb
139 db.login user=myname pass=secret
140 db.connect -p
141 db.tables -p
142
143 See ODBC database driver for details.
144
145 DBF (local, not recommended)
146 Local storage (the dbf/ subdirectory in the mapset must exist or must
147 be created by the user):
148 db.connect driver=dbf database=’$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/’
149 db.tables -p
150
151 See DBF database driver for details.
152
154 db.columns, db.copy, db.drivers, db.login, db.tables, v.db.addtable,
155 v.db.connect
156
157 GRASS SQL interface
158
160 Main author: Radim Blazek, ITC-Irst, Trento, Italy
161 GRASS 7 improvements: Martin Landa, Markus Metz
162
163 Last changed: $Date: 2016-09-11 09:28:22 +0200 (Sun, 11 Sep 2016) $
164
166 Available at: db.connect source code (history)
167
168 Main index | Database index | Topics index | Keywords index | Graphical
169 index | Full index
170
171 © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
172
173
174
175GRASS 7.4.4 db.connect(1)