Arguments
- source_db
A mpathsenser database connection from where the data will be transferred.
- target_db
A mpathsenser database connection where the data will be transferred to.
create_db()to create a new database.- sensor
A character vector containing one or multiple sensors. See
sensorsfor a list of available sensors. Use "All" for all available sensors.
Examples
# First create two databases in a temporary directory
db1 <- create_db(tempdir(), "mydb1.db")
db2 <- create_db(tempdir(), "mydb2.db")
# Populate the first database with some data
DBI::dbExecute(db1, "INSERT INTO Study VALUES ('study_1', 'default')")
#> [1] 1
DBI::dbExecute(db1, "INSERT INTO Participant VALUES ('1', 'study_1')")
#> [1] 1
DBI::dbExecute(db1, "INSERT INTO Activity VALUES(
'123', '1', '2024-01-01', '08:00:00', '100', 'WALKING')")
#> [1] 1
# Then copy the first database to the second database
copy_db(db1, db2)
# Check that the second database has the same data as the first database
get_data(db2, "Activity")
#> # Source: table<`activity`> [?? x 6]
#> # Database: sqlite 3.51.1 [/tmp/RtmpoNbLQ9/mydb2.db]
#> measurement_id participant_id date time confidence type
#> <chr> <chr> <chr> <chr> <int> <chr>
#> 1 123 1 2024-01-01 08:00:00 100 WALKING
# Cleanup
close_db(db1)
close_db(db2)
file.remove(file.path(tempdir(), "mydb1.db"))
#> [1] TRUE
file.remove(file.path(tempdir(), "mydb2.db"))
#> [1] TRUE
