Archive for the ‘mySQL’ Category

Why you should try Django : Agility

Tuesday, November 4th, 2008

Disclaimer: I’m not naive enough to think that Django is for everybody and that’s why the title reads ‘try’ and not ‘use’. However, I do think after giving Django a chance and breaking out of your cycle you will be impressed. I also realize due to where I’m aggregated I’m preaching too many of the converted. However, perhaps if nothing else this will help your arguments when persuading others or your work to give Django a go. I’m also going to assume you know nothing about Django or even much about programming. Finally, I write this as I am getting [...]

Getting Django up and running on Centos 5.2 with Apache(mod_python) and MySQL

Thursday, October 9th, 2008

This is partly for my reference (doing it the second time just now and I forgot everything!) but hopefully it will be helpful for others too.
Disclaimer; I am by no means a Linux expert. This is just how I got it working… If there is a better, easier or wiser way please let me know!
Let’s assume you have Yum installed (I didn’t on my VPS - but my provider installed it for me).
First, make sure you are up to date;

$ yum update

These are the packages I installed (httpd and python are already installed);

mod_python (Apache uses this to run Python)
mysql-server
mysql-devel [...]

Changing default storage engine in MySQL

Wednesday, September 3rd, 2008

This took me a while to figure out so I thought I’d put it here for future reference! I needed to change it so that Django would use innoDB rather that MyISAM, it seemed to just take the default and I couldn’t find an override.
You need to locate the mySQL config file (helpfully named) my.cnf file. On Centos 5.2 it is located at /etc/my.cnf
Then under the [mysqld] add the following line as shown below!

[mysqld]
default-storage_engine = innodb

Finally, restart mySQL;
$ service mysqld restart
It’s pretty easy to do when you know how and now you have transactional tables by default

Recording users by country

Saturday, July 19th, 2008

Detecting a user’s location requires recording and analysing their IP address. Different IP ranges are assigned to different countries. This isn’t always full proof, for example if the ISP is in another country from the user it will be recorded incorrectly. After taking note of the IP the easiest way to detect the country is to use a predefined database such as ip2nation (http://www.ip2nation.com/ ). Ip2nation is a free mySQL database of IP’s and countries. However it is isn’t documented, so takes a moment to work out how you want to use it. You can download it here: http://www.ip2nation.com/ip2nation/Download

SELECT c.country, [...]