1db.copy(1) GRASS GIS User's Manual db.copy(1)
2
3
4
6 db.copy - Copy a table.
7 Either ’from_table’ (optionally with ’where’) can be used or ’select’
8 option, but not ’from_table’ and ’select’ at the same time.
9
11 database, attribute table, SQL
12
14 db.copy
15 db.copy --help
16 db.copy [from_driver=name] [from_database=name] [from_table=name]
17 [to_driver=name] [to_database=name] to_table=name [where=sql_query]
18 [select=string] [--overwrite] [--help] [--verbose] [--quiet]
19 [--ui]
20
21 Flags:
22 --overwrite
23 Allow output files to overwrite existing files
24
25 --help
26 Print usage summary
27
28 --verbose
29 Verbose module output
30
31 --quiet
32 Quiet module output
33
34 --ui
35 Force launching GUI dialog
36
37 Parameters:
38 from_driver=name
39 Input driver name
40 Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
41 Default: sqlite
42
43 from_database=name
44 Input database name
45 Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
46
47 from_table=name
48 Input table name (only, if ’select’ is not used)
49
50 to_driver=name
51 Output driver name
52 Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
53 Default: sqlite
54
55 to_database=name
56 Output database name
57 Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
58
59 to_table=name [required]
60 Output table name
61
62 where=sql_query
63 WHERE conditions of SQL statement without ’where’ keyword
64 Example: income < 1000 and population >= 10000
65
66 select=string
67 Full select statement (only, if ’from_table’ and ’where’ is not
68 used)
69 E.g.: SELECT dedek FROM starobince WHERE obec = ’Frimburg’
70
72 db.copy allows the user to copy a table between two databases. Data‐
73 bases can be connected through different drivers (see examples below).
74
76 Attribute tables can be copied using db.copy and, when to be associated
77 to a vector map, assigned to the map with v.db.connect. Current connec‐
78 tion settings are saved in the file $LOCATION/vector_map/dbln.
79
81 From DBF to PostgreSQL
82 Storing table ’geonames.dbf’ (in current directory) into PostgreSQL
83 through ODBC:
84 db.copy from_driver=dbf from_database=’$GISDBASE/$LOCATION_NAME/PERMANENT/dbf’ \
85 from_table=geonames to_driver=pg to_database="host=pgserver,dbname=testdb" \
86 to_table=geonames
87
88 From PostgreSQL to DBF
89 db.copy from_driver=pg from_database="host=pgserver.example.org,dbname=testdb" \
90 from_table=origtable to_driver=dbf \
91 to_database=’$GISDBASE/$LOCATION_NAME/$MAPSET/dbf’ to_table=origtable
92
93 From PostgreSQL to PostgreSQL with condition
94 db.copy from_driver=pg from_database="host=localhost,dbname=testdb" \
95 from_table=geonames to_driver=pg to_database="host=localhost,dbname=testdb" \
96 to_table=selection where="cat < 500"
97
98 From DBF to SQLite
99 db.copy from_driver=dbf from_database=’$GISDBASE/$LOCATION_NAME/PERMANENT/dbf’ \
100 from_table=geonames_features to_driver=sqlite \
101 to_database=’$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db’ to_table=geonames_features
102 # convenient viewer:
103 sqlitebrowser $HOME/grassdata/nc_spm_08/user1/sqlite/sqlite.db
104
105 From SQLite to DBF
106 db.copy from_driver=sqlite from_database=’$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db’ \
107 from_table=ammprv to_driver=dbf to_database=’$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/’ \
108 to_table=ammprv
109
111 db.connect, db.drivers, db.login, v.db.connect, v.clean
112
113 GRASS SQL interface
114
116 Radim Blazek, ITC-irst, Trento, Italy
117
119 Available at: db.copy source code (history)
120
121 Accessed: Saturday Oct 28 18:17:10 2023
122
123 Main index | Database index | Topics index | Keywords index | Graphical
124 index | Full index
125
126 © 2003-2023 GRASS Development Team, GRASS GIS 8.3.1 Reference Manual
127
128
129
130GRASS 8.3.1 db.copy(1)