Class: Webhookdb::DBAdapter
- Inherits:
-
Object
- Object
- Webhookdb::DBAdapter
show all
- Defined in:
- lib/webhookdb/db_adapter.rb
Defined Under Namespace
Modules: ColumnTypes, DefaultSql
Classes: Column, Connection, Index, PG, Schema, SequelConnection, Snowflake, Table, TableDescriptor, UnsupportedAdapter
Constant Summary
collapse
- VALID_IDENTIFIER =
/^[a-zA-Z][a-zA-Z\d_ ]*$/
- INVALID_IDENTIFIER_MESSAGE =
"Identifiers must start with a letter and " \
"contain only letters, numbers, spaces, and underscores. " \
"See https://docs.webhookdb.com/concepts/valid-identifiers/ for rules " \
"about identifiers like schema, table, and column names."
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
-
#add_column_sql(table, column, if_not_exists: false) ⇒ String
-
#connection(url) ⇒ Connection
Return a new Connection for the adapter.
-
#create_index_sql(index, concurrently:) ⇒ String
-
#create_schema_sql(schema, if_not_exists: false) ⇒ String
-
#create_table_sql(table, columns, schema: nil, if_not_exists: false) ⇒ String
-
#merge_from_csv(connection, file, table, pk_col, copy_columns) ⇒ Object
Given a table and a (temporary) file with CSV data, import it into the table.
-
#verify_connection(url, timeout: 2, statement: "SELECT 1") ⇒ Object
Instance Attribute Details
#name ⇒ Symbol
|
# File 'lib/webhookdb/db_adapter.rb', line 72
|
|
# File 'lib/webhookdb/db_adapter.rb', line 72
|
#targets ⇒ Array<Column>
|
# File 'lib/webhookdb/db_adapter.rb', line 72
|
#unique ⇒ Boolean
|
# File 'lib/webhookdb/db_adapter.rb', line 72
|
Class Method Details
.supported_adapters_message ⇒ Object
202
203
204
|
# File 'lib/webhookdb/db_adapter.rb', line 202
def self.supported_adapters_message
return "Postgres (postgres://), SnowflakeDB (snowflake://)"
end
|
Instance Method Details
#add_column_sql(table, column, if_not_exists: false) ⇒ String
167
168
169
|
# File 'lib/webhookdb/db_adapter.rb', line 167
def add_column_sql(table, column, if_not_exists: false)
raise NotImplementedError
end
|
Return a new Connection for the adapter. By default, return a SequelConnection, but adapters not using Sequel will need their own type.
137
138
139
|
# File 'lib/webhookdb/db_adapter.rb', line 137
def connection(url)
return SequelConnection.new(url)
end
|
#create_index_sql(index, concurrently:) ⇒ String
159
160
161
|
# File 'lib/webhookdb/db_adapter.rb', line 159
def create_index_sql(index, concurrently:)
raise NotImplementedError
end
|
#create_schema_sql(schema, if_not_exists: false) ⇒ String
144
145
146
|
# File 'lib/webhookdb/db_adapter.rb', line 144
def create_schema_sql(schema, if_not_exists: false)
raise NotImplementedError
end
|
#create_table_sql(table, columns, schema: nil, if_not_exists: false) ⇒ String
153
154
155
|
# File 'lib/webhookdb/db_adapter.rb', line 153
def create_table_sql(table, columns, schema: nil, if_not_exists: false)
raise NotImplementedError
end
|
#merge_from_csv(connection, file, table, pk_col, copy_columns) ⇒ Object
Given a table and a (temporary) file with CSV data, import it into the table. Usually this is a COPY INTO command. For PG it would read from stdin, for Snowflake it would have to stage the file.
181
182
183
|
# File 'lib/webhookdb/db_adapter.rb', line 181
def merge_from_csv(connection, file, table, pk_col, copy_columns)
raise NotImplementedError
end
|
#verify_connection(url, timeout: 2, statement: "SELECT 1") ⇒ Object
185
186
187
|
# File 'lib/webhookdb/db_adapter.rb', line 185
def verify_connection(url, timeout: 2, statement: "SELECT 1")
return self._verify_connection(url, timeout:, statement:)
end
|