<?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>emson... &#187; databases</title>
	<atom:link href="http://blog.emson.co.uk/category/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.emson.co.uk</link>
	<description></description>
	<lastBuildDate>Thu, 24 Jun 2010 08:27:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Install Python on Dreamhost Shared Hosting</title>
		<link>http://blog.emson.co.uk/2010/04/how-to-install-python-on-dreamhost-shared-hosting/</link>
		<comments>http://blog.emson.co.uk/2010/04/how-to-install-python-on-dreamhost-shared-hosting/#comments</comments>
		<pubDate>Thu, 01 Apr 2010 16:31:48 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[dreamhost]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/?p=80</guid>
		<description><![CDATA[This article describes how to install and set up Python and VirtualEnv on Dreamhost web site hosting.

Some of these notes are based on this article: 
URL:  http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/

Set up

Log into your shared server and do the following:

$ mkdir -p opt/python261
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.1/Python-2.6.1.tgz
$ tar xvzf Python-2.6.1.tgz


Note that:
According to the Filesystem Hierarchy Standard, [...]]]></description>
			<content:encoded><![CDATA[<p>This article describes how to install and set up Python and VirtualEnv on <a href="http://www.dreamhost.com/r.cgi?105422">Dreamhost web site hosting</a>.</p>

<p>Some of these notes are based on this article: 
URL:  http://blog.localkinegrinds.com/2007/08/20/custom-python-installation-for-django-on-dreamhost/</p>

<h2>Set up</h2>

<p>Log into your shared server and do the following:</p>

<pre><code>$ mkdir -p opt/python261
$ mkdir downloads
$ cd downloads
$ wget http://www.python.org/ftp/python/2.6.1/Python-2.6.1.tgz
$ tar xvzf Python-2.6.1.tgz
</code></pre>

<p>Note that:
According to the <a href="http://www.pathname.com/fhs/pub/fhs-2.3.html#OPTADDONAPPLICATIONSOFTWAREPACKAGES">Filesystem Hierarchy Standard</a>, the /opt dir &#8220;is reserved for the installation of add-on application software packages.&#8221;</p>

<p>Now configure where your new Python instance will be installed:</p>

<pre><code>$ cd Python-2.6.1
$ ./configure --prefix=$HOME/opt/python261
$ make
$ make install &gt; install.txt
</code></pre>

<p>NB: The install.txt file is useful to locate files if you wish to uninstall Python later.
NB: you might wish to use:</p>

<pre><code>$ ./configure --prefix=$HOME/opt/python261  --enable-unicode=ucs4
</code></pre>

<p>But Dreamhost does uses ucs2 by default (Python&#8217;s default to), and there can be issues if you try to load packages that are compiled using a different Unicode setting.</p>

<p>Now edit your ~/.bash_profile file to specify the new Python install located in: ~/opt/</p>

<pre><code>export PATH=$PATH:$HOME/opt/python261/bin
</code></pre>

<p>You might also want to add an alias so that instead of typing <strong>python2.6</strong> to access the python shell, you can just type <strong>python</strong> in the command line.</p>

<pre><code>alias python='python2.6'
</code></pre>

<p>Don&#8217;t forget to tell bash to load this file after you have made your changes:</p>

<pre><code>$ source ~/.bash_profile
$ python -V  # will display your new version 2.6.1
</code></pre>

<h2>Installing VirtualEnv</h2>

<pre><code>$ cd downloads/
$ curl -O http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.4.5.tar.gz
$ tar -xvzf virtualenv-1.4.5.tar.gz
$ python virtualenv-1.4.5/virtualenv.py $HOME/virtual --no-site-packages
</code></pre>

<p>NB: This binds your new install with virtualenv and creates a virtual directory in your user home directory.
You will need to use the <strong>&#8211;no-site-packages</strong> option so that virtualenv doesn&#8217;t use any of the original Dreamhost Python install packages.</p>

<p>Update your <strong>~/.bash_profile</strong> file so that it puts the virtualenv packages onto the Python path, and <em>activate(s)</em> your virtual environment:</p>

<pre><code>export PATH="$PATH:$HOME/opt/python261/bin:$HOME/virtual/bin"
source $HOME/virtual/bin/activate
</code></pre>

<p>Check that the packages directory is in your new virtual <strong>site_packages</strong> directory:</p>

<pre><code>$ python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"
</code></pre>

<p>Now activate your virtual environment, by executing the <strong>.bash_profile</strong> file:</p>

<pre><code>$ source ~/.bash_profile
</code></pre>

<p>Or manually activate it by:</p>

<pre><code>$ . ~/virtual/bin activate
</code></pre>

<h2>Installing MySQL Python Bindings</h2>

<!-- http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz/download -->

<pre><code>(virtual)$ cd downloads
(virtual)$ wget http://internap.dl.sourceforge.net/sourceforge/mysql-python/MySQL-python-1.2.3c1.tar.gz
(virtual)$ tar xvzf MySQL-python-1.2.3c1.tar.gz
(virtual)$ cd MySQL-python-1.2.3c1
(virtual)$ python setup.py install
</code></pre>

<p>Check that you can import the database correctly (NB: do this from a different directory from the one where MySQL-python was installed, as you will get Module already imported warnings):</p>

<pre><code>(virtual)$ cd ~
(virtual)$ python
&gt;&gt;&gt; import MySQLdb
</code></pre>

<p>If you don&#8217;t get an error all succeeded OK.</p>

<h2>Install Django</h2>

<pre><code>(virtual)$ pip install Django
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2010/04/how-to-install-python-on-dreamhost-shared-hosting/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Everyday MySQL Commands</title>
		<link>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/</link>
		<comments>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/#comments</comments>
		<pubDate>Tue, 19 Aug 2008 00:45:51 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[databases]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://blog.emson.co.uk/2008/08/everyday-mysql-commands/</guid>
		<description><![CDATA[I&#8217;m trying to put together a number of blog articles and many of them use the MySQL database, so I figured that I would post up some of my most used everyday MySQL SQL commands.  Most likely I will append further commands as I write more articles so this is page is really a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to put together a number of blog articles and many of them use the MySQL database, so I figured that I would post up some of my most used everyday MySQL SQL commands.  Most likely I will append further commands as I write more articles so this is page is really a work in progress.</p>

<p>I&#8217;ve also assumed that you want to have full rights when executing these commands so I&#8217;ve used <strong>sudo</strong>, however you may not need this depending on your set up.</p>

<p>Finally if some other web site covers the command better or I&#8217;m feeling lazy I&#8217;ll just pop it in the links list at the bottom of this page.</p>

<h2>Useful MySQL Commands</h2>

<h3>Starting MySQL Demon</h3>

<p>Start your MySQL database and get it running as a background process:</p>

<pre><code>sudo mysqld_safe
Ctrl + Z
bg
</code></pre>

<h3>MySQL create databases script</h3>

<p>Make a SQL script that creates 3 databases and assigns all rights to my username.
Copy the following SQL and paste it into a file called <strong>create_databases.sql</strong>:</p>

<pre><code>create database mydb_development;
create database mydb_test;
create database mydb_production;
grant all on mydb_development.* to 'my_username'@'localhost';
grant all on mydb_test.* to 'my_username'@'localhost';
grant all on mydb_production.* to 'my_username'@'localhost' identified by 'my_password';
</code></pre>

<h3>MySQL drop databases script</h3>

<p>Make a script to drop databases.
Copy the following SQL and paste it into a file called <strong>drop_databases.sql</strong>:</p>

<pre><code>drop database nemos_production;
drop database mydb_development;
drop database nemos_test;
</code></pre>

<h3>Executing a script from MySQL</h3>

<p>The above scripts can be executed from the command-line with the either of these commands:</p>

<pre><code>sudo mysql &lt; create_database.sql
or
sudo mysql &lt; drop_database.sql
</code></pre>

<h3>Showing MySQL databases</h3>

<p>To check that the databases were created :</p>

<pre><code>sudo mysqlshow
or
sudo mysql
show databases;
</code></pre>

<h3>Displaying database tables</h3>

<p>Displaying the tables of a database:</p>

<pre><code>sudo mysqlshow mydb_development
or
sudo mysql
show tables from mydb_development;
</code></pre>

<h3>Displaying details about a database table</h3>

<p>Displaying details about a particular database table:</p>

<pre><code>sudo mysqlshow mydb_development mytable
</code></pre>

<h3>Droping a database table</h3>

<p>Dropping a table from a database:</p>

<pre><code>sudo mysql
use mydb_development;
drop table mytable;
</code></pre>

<h3>Displaying information about a table</h3>

<p>Displaying the fields and field metadata about a table:</p>

<pre><code>show fields from my_table; 
or
desc my_table;
</code></pre>

<h2>Useful Links</h2>

<ul>
<li><a href="http://openmaniak.com/mysql.php">http://openmaniak.com/mysql.php</a></li>
</ul>

<p>These are just a few quick and simple MySQL commands that you will always use.
Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.emson.co.uk/2008/08/everyday-mysql-commands/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
