<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>spechal.com &#187; MySQL</title>
	<atom:link href="http://spechal.com/category/mysql/feed/" rel="self" type="application/rss+xml" />
	<link>http://spechal.com</link>
	<description>[spesh-uhl]</description>
	<lastBuildDate>Sat, 24 Dec 2011 03:41:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Very simple MySQL backup bash script</title>
		<link>http://spechal.com/2011/12/23/very-simple-mysql-backup-bash-script/</link>
		<comments>http://spechal.com/2011/12/23/very-simple-mysql-backup-bash-script/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 09:07:07 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Commands]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=308</guid>
		<description><![CDATA[This code backups up mysql databases and gzips them into the current working directory. If you want to backup the mysql table, remove it from the for loop. #!/bin/bash usage(){ echo "Usage $0 &#60;mysql_user&#62; &#60;mysql_password&#62;" exit 1 } if [[ &#8230; <a href="http://spechal.com/2011/12/23/very-simple-mysql-backup-bash-script/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This code backups up mysql databases and gzips them into the current working directory.  If you want to backup the mysql table, remove it from the for loop.</p>
<pre language="bash">#!/bin/bash

usage(){
        echo "Usage $0 &lt;mysql_user&gt; &lt;mysql_password&gt;"
        exit 1
}

if [[ "$2" != "" &#038;&#038; "$2" == "" ]]
then
        usage
fi

USER=$1
PASS=$2
if [ "$3" != "" ]
then
  DB_HOST=$3
else
  DB_HOST="localhost"
fi

for db in `mysql -u$USER -p$PASS -h$DB_HOST -e 'show databases' | cut -f2 | awk '{ print $1 }' | grep -v "Database\|mysql\|information_schema\|test"`;
do
  echo "Working with $db"
  mysqldump -u$USER -p$PASS -h$DB_HOST $db > $db.sql
  gzip $db.sql
done;

echo "Finished";</pre>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2011/12/23/very-simple-mysql-backup-bash-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Python MySQL Associative Array</title>
		<link>http://spechal.com/2009/11/27/python-mysql-associative-array/</link>
		<comments>http://spechal.com/2009/11/27/python-mysql-associative-array/#comments</comments>
		<pubDate>Fri, 27 Nov 2009 23:26:04 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=87</guid>
		<description><![CDATA[By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array. Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP. In addition, we will &#8230; <a href="http://spechal.com/2009/11/27/python-mysql-associative-array/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, the MySQLdb module to access a MySQL database returns the data as an integer indexed array.  Sometimes this is not desirable and an associative array is preferred, such as the mysql_fetch_assoc function in PHP.  In addition, we will be using the pprint module which is similar PHP&#8217;s print_r</p>
<p>Here is the Python equivalent:</p>
<pre class="python" name="code">
import MySQLdb
import pprint
# connect to the database here
db = MySQLdb.connect(...)
c = db.cursor(cursorclass=MySQLdb.cursors.DictCursor)
query = "SELECT `name`, `address` FROM `table`"
c.execute(query)
rows = c.fetchall()
c.close()
pprint.pprint(rows) # i.e. print_r($rows)
</pre>
<p>Hope that helps someone.</p>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2009/11/27/python-mysql-associative-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP function to validate MySQL UUID or GUID</title>
		<link>http://spechal.com/2009/11/15/php-function-to-validate-mysql-uuid-or-guid/</link>
		<comments>http://spechal.com/2009/11/15/php-function-to-validate-mysql-uuid-or-guid/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 23:59:51 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=30</guid>
		<description><![CDATA[/** * Function to validate a generated GUID / UUID * @param string $guid GUID * @return bool */ function validGUID($guid){ return preg_match('#^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$#', $guid); }]]></description>
			<content:encoded><![CDATA[<pre class="php">/**
   *  Function to validate a generated GUID / UUID
   *  @param string $guid GUID
   *  @return bool
   */
  function validGUID($guid){
    return preg_match('#^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$#', $guid);
  }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2009/11/15/php-function-to-validate-mysql-uuid-or-guid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP function to emulate MySQL UUID</title>
		<link>http://spechal.com/2009/11/15/php-function-to-emulate-mysql-uuid/</link>
		<comments>http://spechal.com/2009/11/15/php-function-to-emulate-mysql-uuid/#comments</comments>
		<pubDate>Sun, 15 Nov 2009 23:58:15 +0000</pubDate>
		<dc:creator>Spechal</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://spechal.com/?p=28</guid>
		<description><![CDATA[/** * uuid * * uuid() simply replicates MySQL's UUID function, which returns a 36 * character &#34;random&#34; hash (32 alphanumeric, 4 dashes). * @return string */ function uuid(){ return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) &#124; &#8230; <a href="http://spechal.com/2009/11/15/php-function-to-emulate-mysql-uuid/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<pre class="php" name="code">
/**
   *  uuid
   *
   *  uuid() simply replicates MySQL's UUID function, which returns a 36
   *  character &quot;random&quot; hash (32 alphanumeric, 4 dashes).
   *  @return string
   */
  function uuid(){
    return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
      mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
      mt_rand(0, 0x0fff) | 0x4000,
      mt_rand(0, 0x3fff) | 0x8000,
      mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff));
  }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://spechal.com/2009/11/15/php-function-to-emulate-mysql-uuid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

