CsPro2Sql is a Java application to migrate questionnaires from CsPro 7.0 to a MySQL database.
The MySQL database will contain the microdata ie. a column per each variable (Item
) defined in the CsPro-Dictionary.
Environment:
- Java 1.7+
- MySQL 5.7+
Libraries:
- Apache Commons CLI (commons-cli-1.3.1.jar)
- MySQL Connector/J 5.1.40 (mysql-connector-java-5.1.40-bin.jar)
CsPro2Sql is simple to install: all you need is to download and unzip the CsPro2Sql.zip
. Depending on your system execute from the command line CsPro2Sql.bat
or CsPro2Sql.sh
.
CsPro2Sql is composed of several engines (run CsPro2Sql
to get usage info):
CsPro2Sql -e schema -p PROPERTIES_FILE [-fk] [-o OUTPUT_FILE]
CsPro2Sql -e loader -p PROPERTIES_FILE [-a] [-cc] [-co] [-f|-r] [-o OUTPUT_FILE]
CsPro2Sql -e monitor -p PROPERTIES_FILE [-o OUTPUT_FILE]
CsPro2Sql -e update -p PROPERTIES_FILE
CsPro2Sql -e status -p PROPERTIES_FILE
Engines description:
schema
: to create the microdata MySQL scriptloader
: to transfer data from the CsPro 7.0 database to the microdata MySQL databasemonitor
: to create the dashboard MySQL scriptupdate
: to update the dashboard report datastatus
: to check the loader engine status
Parameters:
-a,--all transfer all the questionnaires
-cc,--check-constraints perform constraints check
-co,--check-only perform only constraints check (no data transfer)
-e,--engine <arg> select engine: [loader|schema|monitor|update|status]
-f,--force skip check of loader multiple running instances
-fk,--foreign-keys create foreign keys to value sets
-h,--help display this help
-o,--output <arg> name of the output file
-p,--properties <arg> properties file
-r,--recovery recover a broken session of the loader
-v,--version print the version of the programm
In order to run CsPro2Sql engines it is necessary to configure a properties file. Such file must contain the following properties:
db.source.uri
: CsPro 7.0 database connection stringdb.source.schema
: CsPro 7.0 database schemadb.source.username
: CsPro 7.0 database usernamedb.source.password
: CsPro 7.0 database passworddb.source.data.table
: CsPro 7.0 table containing questionnaires plain datadb.dest.uri
: microdata MySQL connection stringdb.dest.schema
: microdata MySQL schemadb.dest.username
: microdata MySQL usernamedb.dest.password
: microdata MySQL passworddb.dest.table.prefix
: microdata MySQL table prefix
Within this configuration CsPro2Sql reads the CsPro-Dictionary from CsPro 7.0 database. It is also possible to specify a CsPro-Dictionary file:
dictionary.filename
: the path to the CsPro-Dictionary file
Optional properties are:
multiple.response
: list of items to be considered as a multiple answer (comma separated)ignore.items
: list of items to be ignored (comma separated)
Note: the source CsPro 7.0 database and the microdata MySQL could be the same
Example of properties file (eg. Household.properties
):
# Source CsPro database
db.source.uri=jdbc:mysql://localhost:3306
db.source.schema=cspro
db.source.username=srcUsername
db.source.password=srcPassword
db.source.data.table=household_dict
# Destination microdata MySQL
db.dest.uri=jdbc:mysql://localhost:3306
db.dest.schema=cspro_microdata
db.dest.username=dstUsername
db.dest.password=dstPassword
db.dest.table.prefix=h
Execution steps:
> CsPro2Sql -e schema -p Household.properties –o microdata.sql
> mysql -u dstUsername -p < microdata.sql
> CsPro2Sql -e loader -p Household.properties –cc
To monitor the loader activity run:
> CsPro2Sql -e status -p Household.properties
- The CsPro tag
[Relation]
is ignored - A
ValueSet
with more than 1000 elements is ignored (the threshold will be parameterized in future realesed)
The team responsible of Census and Survey Processing System (CSPro)
CsPro2Sql is EUPL-licensed