DbShell

OpenSource database automation toolkit

User Tools

Site Tools


samples:csv_export_with_custom_fields

CSV export with custom fields

This scripts creates semicolon delimited CSV with 3 columns - ID, Artist, Album. Id is combination of AlbumId and ArtistId.

DbShell Script

CopyTable(
  source = Query("""select Album.Title as Album, Artist.Name as Artist, Artist.ArtistId, Album.AlbumId
      from Album
      inner join Artist on Album.ArtistId = Artist.ArtistId
  """),
  target = CsvFile(name = "AlbumComplex.csv", delimiter = ";"),
  clearTarget = true
)
columnMap {
  MapValue(name = "ID", Value = "${AlbumId}-${ArtistId}");
  MapColumn(name = 'Artist');
  MapColumn(name = 'Album');
}
samples/csv_export_with_custom_fields.txt · Last modified: 2018/04/21 19:17 by admin