<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 13, 2015, at 08:05, Rob Funk &lt;<a href="mailto:rfunk@funknet.net" class="">rfunk@funknet.net</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Rick Hornsby wrote:<br class=""><blockquote type="cite" class="">I'm trying to write a Ruby script (not RoR) using ActiveRecord. &nbsp;The<br class="">documentation is confusing to say the least, probably because while I<br class="">know what it is, I've never worked with ActiveRecord before.<br class=""></blockquote><br class="">Yikes. Most ActiveRecord documentation is oriented toward use inside<br class="">Rails (or maybe vice-versa), so you're not going the easy way here.<br class=""></div></blockquote><div><br class=""></div><div>This helps - thanks. &nbsp;I don't feel quite as stupid now. &nbsp;I went toward ActiveRecord thinking that's what I should be using. &nbsp;While so many hits for "Ruby mysql" say to use the mysql gem, the author says that the gem is deprecated[1] so I went hunting for another solution.</div><div><br class=""></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><blockquote type="cite" class="">I’m having a hard time finding somewhere that shows both the has_one<br class="">syntax and how to actually use that to retrieve records - because<br class="">other places show using a Class.join syntax - but not how or if it<br class="">relates to the has_one syntax in the class?<br class=""><br class="">Sorry - very confused. I know I'm missing something, but I'm not<br class="">sure what?<br class=""></blockquote><br class="">I think what you're missing is that ActiveRecord is a bad fit for your<br class="">task.<br class=""></div></blockquote><div><br class=""></div>Yes. I agree with your assessment.<br class=""><div><br class=""></div><blockquote type="cite" class=""><div class="">I wonder if Sequel would be a better fit, since it's designed for use<br class="">outside Rails, though it may have some of the same naming issues as<br class="">ActiveRecord. &nbsp;<a href="http://twin.github.io/ode-to-sequel/" class="">http://twin.github.io/ode-to-sequel/</a><br class=""></div></blockquote></div><br class=""><div class=""><div>I could do all of this in Perl with DBI, but I'm forcing myself to learn/practice Ruby and I'm already using the super easy vacuum gem to fetch from the Amazon API.</div><div><br class=""></div><div>I hadn't seen the mysql2 gem[2] until I went to go back to find the link for the mysql gem[1]. mysql2 appears to be maintained. That should work better. &nbsp;I'm not trying to do anything crazy that demands I use ActiveRecord. &nbsp;AR seems very interesting to learn, but not an appropriate tool for this.</div></div><div class=""><br class=""></div><div class="">Background- SONGLIST comes from the database behind SpacialAudio. The SONGLIST table has some bad track metadata - especially the genre. &nbsp;Most genres are missing, and many are wrong. &nbsp;For about 75% of the ~20,000 tracks, I have a UPC. &nbsp;I need to call the Amazon product API, and store the associated JSON response. I can then process the JSON response offline (i.e. to get the genre) without having to call the Amazon API 16,000 * N times because I didn't account for something. &nbsp;I looked at other APIs including FreeDB and Gracenote - none of them appear to be capable of &nbsp;processing a request by a unique identifier I have available i.e. UPC. One might take the hex disc ID, but I don't have that data.</div><div class=""><br class=""></div><div class=""><div>I think a standard mysql interface will be fine for this, but I'll keep Sequel in mind.</div></div><div><br class=""></div><div>thanks again!</div><div>-rick</div><div class=""><br class=""></div><div class=""><div>[1]&nbsp;<a href="https://rubygems.org/gems/mysql/versions/2.9.1" class="">https://rubygems.org/gems/mysql/versions/2.9.1</a></div><div>[2]&nbsp;<a href="https://rubygems.org/gems/mysql2/versions/0.3.18" class="">https://rubygems.org/gems/mysql2/versions/0.3.18</a></div></div><div class=""><br class=""></div></body></html>