| 1 |
# Transform all records of input sqlite table to json file |
| 2 |
|
| 3 |
[etl] |
| 4 |
chains = input_sqlite_all|convert_records_to_json|output_cities_file, |
| 5 |
input_sqlite_single|convert_record_to_json|output_city_file |
| 6 |
|
| 7 |
# |
| 8 |
# CHAIN 1 - Multi Record case |
| 9 |
# |
| 10 |
|
| 11 |
# Read all records from SQLite DB into record array |
| 12 |
[input_sqlite_all] |
| 13 |
class = stetl.inputs.dbinput.SqliteDbInput |
| 14 |
output_format = record_array |
| 15 |
database_name = input/cities.sdb |
| 16 |
table = cities |
| 17 |
read_once = True |
| 18 |
query = select * from cities |
| 19 |
|
| 20 |
# Use the standard converter to convert record array to struct (dict) |
| 21 |
[convert_records_to_json] |
| 22 |
class = stetl.filters.formatconverter.FormatConverter |
| 23 |
input_format = record_array |
| 24 |
output_format = struct |
| 25 |
converter_args = { |
| 26 |
'top_name': 'cities' |
| 27 |
} |
| 28 |
|
| 29 |
[output_cities_file] |
| 30 |
class = stetl.outputs.fileoutput.FileOutput |
| 31 |
file_path = output/cities.json |
| 32 |
|
| 33 |
# |
| 34 |
# CHAIN 2 - Single Record case |
| 35 |
# |
| 36 |
|
| 37 |
# Read single record from SQLite DB into record |
| 38 |
[input_sqlite_single] |
| 39 |
class = stetl.inputs.dbinput.SqliteDbInput |
| 40 |
output_format = record |
| 41 |
database_name = input/cities.sdb |
| 42 |
table = cities |
| 43 |
read_once = True |
| 44 |
query = select * from cities where name = 'Rome' |
| 45 |
|
| 46 |
# Use the standard converter to convert record to struct (dict) |
| 47 |
[convert_record_to_json] |
| 48 |
class = stetl.filters.formatconverter.FormatConverter |
| 49 |
input_format = record |
| 50 |
output_format = struct |
| 51 |
converter_args = { |
| 52 |
'top_name': 'city' |
| 53 |
} |
| 54 |
|
| 55 |
[output_city_file] |
| 56 |
class = stetl.outputs.fileoutput.FileOutput |
| 57 |
file_path = output/city.json |
| 58 |
|
| 59 |
|