struct
Triki::Postgres
- Triki::Postgres
- Triki::Base
- Struct
- Value
- Object
Overview
PostgreSQL dump parser and writer.
Handles COPY ... FROM stdin statements produced by pg_dump.
Included Modules
- Triki::ConfigScaffoldGenerator
Defined in:
triki/postgres.crInstance Method Summary
-
#make_insert_statement(table_name : String, column_names : ColumnList, values : Array(Array(RowContent)), ignore = false) : String
Reassembles an INSERT/COPY statement from the given rows.
-
#make_valid_value_string(value : RowContent) : RowContent
Quotes or formats a single value for the target database dialect.
-
#parse(obfuscator : Triki, config : ConfigHash, input_io : IO, output_io : IO) : Nil
Postgres uses COPY statements instead of INSERT and look like:
-
#rows_to_be_inserted(line : String) : Array(Array(String | Nil))
Copy statements contain the column values tab separated like so: blah blah blah blah which we want to turn into: [['blah','blah','blah','blah']]
- #table_data(line)
Instance methods inherited from module Triki::ConfigScaffoldGenerator
config_table_close
config_table_close,
config_table_open(table_name)
config_table_open,
emit_scaffold(table_name : String, existing_config : ConfigTableHash | Nil, extra_columns : ColumnList, columns_to_scaffold : ColumnList, output_io : IO)
emit_scaffold,
formatted_line(column : String, definition : ConfigColumn | String, comment : String | Nil = nil) : String
formatted_line,
generate_config(obfuscator : Triki, config : ConfigHash, input_io : IO, output_io : IO)
generate_config
Instance methods inherited from struct Triki::Base
initialize
initialize,
make_insert_statement(table_name : String, column_names : ColumnList, values : Array(Array(RowContent)), ignore = false) : String
make_insert_statement,
make_valid_value_string(value : RowContent) : RowContent
make_valid_value_string,
parse(obfuscator : Triki, config : ConfigHash, input_io : IO, output_io : IO) : Nil
parse,
rows_to_be_inserted(line : String) : Array(Array(String | Nil))
rows_to_be_inserted
Constructor methods inherited from struct Triki::Base
new
new
Instance Method Detail
Reassembles an INSERT/COPY statement from the given rows.
Quotes or formats a single value for the target database dialect.
Postgres uses COPY statements instead of INSERT and look like:
COPY some_table (a, b, c, d) FROM stdin; 1 2 3 4 5 6 7 8 .
This requires the parse methods to persist data (table name and column names) across multiple lines.
Copy statements contain the column values tab separated like so: blah blah blah blah which we want to turn into: [['blah','blah','blah','blah']]
We wrap it in an array to keep it consistent with MySql bulk obfuscation (multiple rows per insert statement)