[mythtv-users] MySQL script for mythfilldatabase

Raymond Wagner raymond at wagnerrp.com
Sun Feb 27 03:56:40 UTC 2011


On 2/26/2011 13:32, Josu Lazkano wrote:
> source=`mysql --database=${DBName} --user=${DBUserName}
> --password=${DBPassword} -sN -e "select sourceid from videosource
> where name='sat'"`
>
> Now I will continue configuring the mythfilldatabase script.

Perhaps you might want to switch to a language like Perl or Python or 
even PHP (we've got bindings for that now too) that has real MySQL support.

For example, here would be the Python version.

###########################
from MythTV import DBData, System
class VideoSource( DBData ):
     @classmethod
     def fromName(cls, name):
         try:
             return cls._fromQuery("WHERE name=%s", (name,)).next()
         except:
             raise Exception("No Videosource matching that name found")
vs = VideoSource.fromName('sat')
print "Running VideoSource {0.name}({0.sourceid})".format(vs)
mfd = System('/usr/local/bin/mythfilldatabase')
try:
     mfd.command('--file', VideoSource.fromName('sat').sourceid, 
'/path/to/xmltvdata.xml')
     print "Mythfilldatabase run successfully"
except:
     print "Mythfilldatabase failed with error code 
{0}".format(mfd.returncode)
     print mfd.stderr
############################

The output would be
     Running VideoSource sat(1)
     Mythfilldatabase run successfully
or
     Running VideoSource sat(1)
     Mythfilldatabase failed with error code <some integer>
<bunch of stderr text>


More information about the mythtv-users mailing list