Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Friday, November 16, 2012

mysql.sock SYMLink and sudo on MacOSX


Today I was trying to configure MySQL driver with Python on my Mac Machine. Everything went smooth but on connecting MySQL I was getting socket error as driver was pointing out to /tmp/mysql.sock

I made symlink of .pid file and it worked but when I used similar ln-s command for making symlink. It did not give any error. On doing ls-la it showed as well but on doing again it got removed. It was weird. On further investigation I learnt that .sock symlinks can't work without root access.

Moral of the story. Use Sudo where ever you can! :)

Sunday, October 02, 2011

MySQL to JSON on Github


This morning I tried to fiddle with Git, a version control system by Linus Trovals. Github is a social coding website which has definitely beaten sourceforge.

For long time I had been thinking to test it out and transfer my only open source contribution, MySQL2Json, a PHP class to convert mysql resultset into JSON. The class actually released in 2006. At that time there was no built-in support of JSON encoding in PHP.

Lots of people who used it asked me to move it to Github but I was not getting time to focus on it. This morning I finally did it. The URL of the code is given below:


https://github.com/kadnan/MySQL2JSON


I am not so good at Licensing thing. The prior code released under PHP License. If it allows you to contribute then do it otherwise let me know. So make a fork and improve it, fix it if necessary.

Happy coding.

Wednesday, August 31, 2011

How to find Query Source in MySQL general Log

Most of the time similar queries are used in different modules of the code-base. At times it gets difficult to find out the page where buggy or slow query is being executed. MySQL provides the option of logging slow and general queries in files. In order to record the source of the executed query it is best that you append a string in query which is then being executed via mysql_query() function of PHP.

$sql = "-- Executed via yourfilename.php:
SELECT * from table;"
;
$resulr = mysql_query($sql,$connection);



By doing this you can now find out where your query got executed. Easy and handy, No? :-)