https://github.com/hellonico/sync-schema
Poor man's sync tool from CSV to SQL database (oracle)
https://github.com/hellonico/sync-schema
Last synced: 9 months ago
JSON representation
Poor man's sync tool from CSV to SQL database (oracle)
- Host: GitHub
- URL: https://github.com/hellonico/sync-schema
- Owner: hellonico
- Created: 2018-10-24T07:58:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-24T08:19:31.000Z (over 7 years ago)
- Last Synced: 2025-05-14T08:10:21.127Z (12 months ago)
- Language: Java
- Size: 93.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# goal
Import data from csv files to SQL database via JDBC.
On first import, the table will be created as needed. Columns are all the same with datatype string.
On successive imports, the table will be added columns (not removed) to reflect CSV file update.
Column names are stripped of ' ' and '_' and lowercase-d.
Data is streamed from the CSV file, so constant rather low (for java) memory usage.
# to run the basic test
```
./demo.sh
```
Which calls:
```
./gradlew run --args src/test/resources/sync.properties
```
With the sync properties file below:
```
inputFile=src/test/resources/sales.csv
dbURL=jdbc:sqlite:sample.db
tableName=sales
tableSchema=null
password=
username=
```
This will read values from the file
```
src/test/java/resources/sales.csv
```
and store data in table named **sales** in a newly (or existing) sqllite database: __sample.db__
# programmatically
```
Properties props = new Properties();
props.load(App.class.getClassLoader().getResourceAsStream("sync.properties"));
App app = new App();
app.execute(props);
```
with a similar property file with the following content
```
inputFile=src/test/resources/sales.csv
dbURL=jdbc:sqlite:sample.db
tableName=sales
# debug=true
```
Will execute the same.
App is not thread safe, but can be reused for a new import.
## oracle
this runs ok on oracle. Here is a sample oracle.properties file to use with the sync-er
```
inputFile=src/test/resources/sales.csv
dbURL=jdbc:oracle:thin:@localhost:1521:orcl
tableName=sales
username=username
password=password
columnType=varchar2 (50)
```