Replies: 1 comment 1 reply
-
This is expected. In general, you should always use a symbol or Sequel-specific object for table names (
You probably want to use table = "prefixorigins#{@id}".to_sym
@db.create_table! table do
column :prefix, 'cidr', primary_key: true
column :asns, 'asn[]'
end
DB[table].import([:prefix, :asns], @data.map { |entry| [entry[0], Sequel.pg_array(entry[1])]}) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
currently I have the following code:
With
create_table!
I can specify the table name as a string, but not when inserting the data. Is this how it should be? Is there a way to specify it as a string there as well?The second question is if there is a nicer way than my
.map
to insert data into a table? Basically I have an array, however I need to convert that array to a hash so I can insert it. Is there a better way there? Maybe keeping it in an array and specifying the data by column order?vs
Beta Was this translation helpful? Give feedback.
All reactions