BUG - Reconnecting to database before SQL queries to avoid timeouts when processing large videos. Also preventing loops in sql_query.

git-svn-id: http://svn.montala.net/svn/resourcespace@5194 c08608d7-6e46-0410-86ca-f2a6f1370df5