<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>has_many :thoughts: Tag MySQL</title>
    <link>http://blog.kineticweb.com/articles/tag/mysql</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Musings from a Ruby on Rails development team</description>
    <item>
      <title>Exporting data from SQLite</title>
      <description>&lt;p&gt;I recently discovered that sqlite3 has a number of output modes to spit out query results in different formats:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;.mode MODE ?TABLE?   Set output mode where MODE is one of:

csv      Comma-separated values
column   Left-aligned columns.  (See .width)
html     HTML &amp;lt;table&amp;gt; code
insert   SQL insert statements for TABLE
line     One value per line
list     Values delimited by .separator string
tabs     Tab-separated values
tcl      TCL list elements&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;By specifying &lt;code&gt;.mode insert&lt;/code&gt; one can get nicely formatted insert statements that can be imported right into MySQL. This is what I did to convert my Voicemail app to MySQL. However, if you don&amp;#8217;t specify a table name on the same line, the resulting insert statements just say &amp;#8220;insert into table&amp;#8221;. One must use &lt;code&gt;.mode insert voicemails&lt;/code&gt; to get insert statements out of sqlite3 that read &amp;#8220;insert into voicemails&amp;#8221;. A bit silly if you ask me&amp;#8230; one would think the table name in the insert statements would just default to the name of the table you were selecting from. But, this worked great for me and was all I needed to get converted.&lt;/p&gt;</description>
      <pubDate>Sun, 03 Feb 2008 09:50:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:39df7e5a-240c-43b9-94f8-2fc17746c8e8</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2008/02/03/exporting-data-from-sqlite</link>
      <category>sqlite</category>
      <category>MySQL</category>
    </item>
    <item>
      <title>securing your database.yml</title>
      <description>&lt;p&gt;During the Intro to Rails portion of tonight&amp;#8217;s Philly on Rails, a question was raised asking if there was a better way to give Rails your database password, rather then storing it in the database.yml file.&lt;/p&gt;


	&lt;p&gt;I tried the method below, which seems to work:&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="ident"&gt;development&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt;
  &lt;span class="ident"&gt;adapter&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="ident"&gt;mysql&lt;/span&gt;
  &lt;span class="ident"&gt;database&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="ident"&gt;whatever_development&lt;/span&gt;
  &lt;span class="ident"&gt;username&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="ident"&gt;whatever&lt;/span&gt;
  &lt;span class="ident"&gt;password&lt;/span&gt;&lt;span class="punct"&gt;:&lt;/span&gt; &lt;span class="punct"&gt;&amp;lt;%=&lt;/span&gt;&lt;span class="string"&gt; gets %&amp;gt;
  socket: /tmp/mysql.sock&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;The first time the database is accessed by Rails, you can simply enter the password at the script/server prompt and you&amp;#8217;re in business.&lt;/p&gt;


	&lt;p&gt;However, I&amp;#8217;m not sure how this would work with the -d option on script/server. I imagine it would not work.&lt;/p&gt;


	&lt;p&gt;Update: &lt;a href="http://pragdave.pragprog.com/pragdave/2007/04/prompting_for_r.html"&gt;PragDave has some thoughts on this, too.&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Mon, 06 Aug 2007 18:43:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d75b24a9-b775-416d-a8d2-3f121dbe9501</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/08/06/securing-your-database-yml</link>
      <category>Rails</category>
      <category>security</category>
      <category>MySQL</category>
      <trackback:ping>http://blog.kineticweb.com/articles/trackback/52</trackback:ping>
    </item>
    <item>
      <title>SQLite vs. MySQL/etc...</title>
      <description>&lt;p&gt;After reading about the wonderful release of mother &lt;a href="http://www.joyent.com"&gt;Joyent&amp;#8217;s&lt;/a&gt; &lt;a href="http://www.joyent.com/developers/slingshot/"&gt;Slingshot&lt;/a&gt; the other day, I noticed that in the docs it said Slingshot uses &lt;a href="http://www.sqlite.org/index.html"&gt;SQLite&lt;/a&gt; on desktop clients. I thought that this was pertaining to personal preference, support the underdog kinda thing. That was wrong, SQLite is easier on memory because it uses file-io instead of in-memory db access&amp;#8230;&lt;/p&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;For low load websites, SQLite has worked great in our projects. If you&amp;#8217;re doing an application in C, its &lt;span class="caps"&gt;API&lt;/span&gt; is simply unbeatable. Perhaps its most distinguishing feature is that it pretty much ignores types. This is, in fact, a &amp;#8220;feature&amp;#8221;, and I have found that it gives it flexibility that is lacking in other situations(although, you have to put your dates in very specific formats to get the sort order to come out right&amp;#8230;).&amp;#8221;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;For web development purposes, if you&amp;#8217;re doing a really high load website, you&amp;#8217;re going to want to use a non-file based database(personally, I prefer PostgreSQL, but sub MySQL, &lt;span class="caps"&gt;SQL&lt;/span&gt; Server, whatever&amp;#8230;)&amp;#8221;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;&amp;#8220;I also can&amp;#8217;t express just how great it is for desktop apps though. Its great for 95% of the situations you would need to save data in an application in a &amp;#8220;file format&amp;#8221; of some variety. It make debugging great(fire up the console on the file your app is writing too and watch inserts as they happen). No configuration at all. No mucking about with binary file formats. No &lt;span class="caps"&gt;XML&lt;/span&gt; parsing.&amp;#8221;&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;blockquote&gt;
		&lt;p&gt;(&lt;a href="http://discuss.joelonsoftware.com/default.asp?design.4.281660.5"&gt;external quote&lt;/a&gt;)&lt;/p&gt;
	&lt;/blockquote&gt;


	&lt;p&gt;I have heard many Rails users glorify the use of SQLite as a testing db&amp;#8230; choose wisely! For me, I think I&amp;#8217;ll stick to what my apps will probably be using as there primary production db, MySQL. :)&lt;/p&gt;</description>
      <pubDate>Fri, 11 May 2007 08:41:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:e36d9d11-a7b0-4ecf-9743-0377644e49c3</guid>
      <author>Justin Reagor</author>
      <link>http://blog.kineticweb.com/articles/2007/05/11/sqlite-vs-mysql</link>
      <category>Rails</category>
      <category>database</category>
      <category>sqlite</category>
      <category>MySQL</category>
    </item>
    <item>
      <title>MySQL find/replace</title>
      <description>&lt;p&gt;&lt;strong&gt;&lt;span class="caps"&gt;NEAT&lt;/span&gt;!&lt;/strong&gt;&lt;/p&gt;


	&lt;p&gt;I just discovered (thanks Google!) that you can do find/replace within strings inside a MySQL table. In this case, I had to push a website live that contained product descriptions in which the client had referenced the development site &lt;span class="caps"&gt;URL&lt;/span&gt;. So:&lt;/p&gt;


&lt;code&gt;
update products set description = replace(description, 'beta.', 'www.'); 
&lt;/code&gt;

	&lt;p&gt;Worked like a charm. I was about to do a &lt;code&gt;mysqldump&lt;/code&gt; and do something with &lt;code&gt;sed&lt;/code&gt; and &lt;code&gt;grep&lt;/code&gt; and then have to re-import the table. But this worked great.&lt;/p&gt;</description>
      <pubDate>Thu, 10 May 2007 16:35:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:0a339071-773d-484b-8acb-cedfdf23b0d4</guid>
      <author>Colin A. Bartlett</author>
      <link>http://blog.kineticweb.com/articles/2007/05/10/mysql-find-replace</link>
      <category>MySQL</category>
    </item>
  </channel>
</rss>
