On Sunday, January 6, 2019 at 2:04:30 PM UTC-8, [email protected] wrote: > > Jeremy, thank you very much. The Dataset#import indeed looks very > promising. I just tried it and works fine but what I went to complicate the > things I faced a problem. In you documentation you say that the table names > and columns names need to b prefaced with semicolon: > > DB[:table].import([:x, :y], [[1, 2], [3, 4]]) >
Well, they need to be prefaced with a colon (:), not a semicolon (;), but that's not a requirement, it's just the ruby syntax that creates symbols. You could also do: DB['table'.to_sym].import(['x'.to_sym, 'y'.to_sym], [[1, 2], [3, 4]]) > As I put in use dynamic target table names, dynamic columns names and > parsed json for values I realized that the semicolon is not just a > delimiter but some kind element of Ruby syntax. How should I deal with > it? Defining the columns as string :k1, :k2, :k2 does not work. Setting > semicolon before the variable like this client[:@table].import is barking > and is not recognizing the table and data object. I am sure it should be > an easy way to do it. > Assuming your table and column names are stored as strings in instance variables, you could do something like: DB[@table.to_sym].import([@col1.to_sym, @col2.to_sym], [[1, 2], [3, 4]]) Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
