DatabaseIOIfc

interface DatabaseIOIfc

An interface that defines basic I/O capabilities for a database.

Inheritors

Properties

Link copied to clipboard
abstract var defaultSchemaName: String?

Sets the name of the default schema

Link copied to clipboard
abstract var label: String

identifying string representing the database. This has no relation to the name of the database on disk or in the dbms. The sole purpose is for labeling of output

Link copied to clipboard
Link copied to clipboard
abstract val schemaNames: List<String>
Link copied to clipboard

The returned map may have a null key because not all databases support the schema concept. There can be table names associated with null as the key.

Link copied to clipboard
abstract val views: Map<String?, List<String>>

The returned map may have a null key because not all databases support the schema concept. There can be view names associated with null as the key.

Functions

Link copied to clipboard
abstract fun exportAllTablesAsCSV(schemaName: String? = defaultSchemaName, pathToOutPutDirectory: Path = outputDirectory.csvDir, header: Boolean = true)

Writes all tables as separate comma separated value files into the supplied directory. The files are written to text files using the same name as the tables in the database

Link copied to clipboard
abstract fun exportAllTablesAsInsertQueries(schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_TableInserts.sql"))

Writes all table data as insert queries to the PrintWriter

Link copied to clipboard
abstract fun exportAllViewsAsCSV(schemaName: String? = defaultSchemaName, pathToOutPutDirectory: Path = outputDirectory.csvDir, header: Boolean = true)

Writes all tables as separate comma separated value files into the supplied directory. The files are written to text files using the same name as the tables in the database

Link copied to clipboard
abstract fun exportInsertQueries(tableName: String, schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_${tableName}_Inserts.sql"))

Writes the insert queries associated with the supplied table to the PrintWriter

Link copied to clipboard
abstract fun exportTableAsCSV(tableName: String, schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${tableName}.csv"), header: Boolean = true)

Writes the table as comma separated values

Link copied to clipboard
abstract fun exportToExcel(schemaName: String? = defaultSchemaName, wbName: String = label, wbDirectory: Path = outputDirectory.excelDir)

Writes each table in the schema to an Excel workbook with each table being placed in a new sheet with the sheet name equal to the name of the table. The column names for each table are written as the first row of each sheet.

abstract fun exportToExcel(tableNames: List<String>, schemaName: String? = defaultSchemaName, wbName: String = label.substringBeforeLast("."), wbDirectory: Path = outputDirectory.excelDir)

Writes each table in the list to an Excel workbook with each table being placed in a new sheet with the sheet name equal to the name of the table. The column names for each table are written as the first row of each sheet.

Link copied to clipboard
abstract fun importSheetToTable(sheet: Sheet, tableName: String, numColumns: Int, schemaName: String? = defaultSchemaName, numRowsToSkip: Int = 1, rowBatchSize: Int = 100, unCompatibleRows: PrintWriter = outputDirectory.createPrintWriter("BadRowsForSheet_${sheet.sheetName}")): Boolean

Copies the rows from the sheet to the table. The copy is assumed to start at row 1, column 1 (i.e. cell A1) and proceed to the right for the number of columns in the table and the number of rows of the sheet. The copy is from the perspective of the table. That is, all columns of a row of the table are attempted to be filled from a corresponding row of the sheet. If the row of the sheet does not have cell values for the corresponding column, then the cell is interpreted as a null value when being placed in the corresponding column. It is up to the client to ensure that the cells in a row of the sheet are data type compatible with the corresponding column in the table. Any rows that cannot be transfer in their entirety are logged to the supplied PrintWriter

Link copied to clipboard
abstract fun importWorkbookToSchema(pathToWorkbook: Path, tableNames: List<String>, schemaName: String? = defaultSchemaName, skipFirstRow: Boolean = true)

Opens the workbook for reading only and writes the sheets of the workbook into database tables. The list of names is the names of the sheets in the workbook and the names of the tables that need to be written. They are in the order that is required for entering data so that no integrity constraints are violated. The underlying workbook is closed after the operation.

Link copied to clipboard
abstract fun printAllTablesAsInsertQueries(schemaName: String? = defaultSchemaName)

Prints all table data as insert queries to the console

Link copied to clipboard
abstract fun printAllTablesAsMarkdown(schemaName: String? = defaultSchemaName)

Prints all tables as text to the console

Link copied to clipboard
abstract fun printAllTablesAsText(schemaName: String? = defaultSchemaName)

Prints all tables as text to the console

Link copied to clipboard
abstract fun printInsertQueries(tableName: String, schemaName: String? = defaultSchemaName)

Prints the insert queries associated with the supplied table to the console

Link copied to clipboard
abstract fun printTableAsCSV(tableName: String, schemaName: String? = defaultSchemaName, header: Boolean = true)

Prints the table as comma separated values to the console

Link copied to clipboard
abstract fun printTableAsMarkdown(tableName: String, schemaName: String? = defaultSchemaName)

Prints the table as prettified text to the console

Link copied to clipboard
abstract fun printTableAsText(tableName: String, schemaName: String? = defaultSchemaName)

Prints the table as prettified text to the console

Link copied to clipboard
abstract fun writeAllTablesAsMarkdown(schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_Tables.md"))

Writes all tables as text

Link copied to clipboard
abstract fun writeAllTablesAsText(schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_Tables.txt"))

Writes all tables as text

Link copied to clipboard
abstract fun writeAllViewsAsMarkdown(schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_Views.md"))

Writes all tables as text

Link copied to clipboard
abstract fun writeTableAsMarkdown(tableName: String, schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_${tableName}.md"))

Writes the table as prettified text.

Link copied to clipboard
abstract fun writeTableAsText(tableName: String, schemaName: String? = defaultSchemaName, out: PrintWriter = outputDirectory.createPrintWriter("${label}_${tableName}.txt"))

Writes the table as prettified text.