[mythtv-users] About Python & Perl

Raymond Wagner raymond at wagnerrp.com
Mon Dec 19 02:29:55 UTC 2011


On 12/18/2011 14:09, Michael Papet wrote:
>>> For what it's worth, in that specific case, neither the Perl nor the Python bindings would provide much help.  Direct manipulation of the channel tables is not something commonly done, so there are no helper utilities or classes in either to make it easier to do so.
>> I've looked at some of the tools that use the bindings and you still need to "use DBI;" correct? So that's not wrong. So the only thing, as you said, it would provide, is the credentials. That, of course, would be no small thing.
> Passing date in/out of the mythconverg database requires no Myth-specific Perl/Python hooks.  Note, I said myth specific.  "Use DBI;" and then a connection stanza and then a prepare statement, and then an execute, and then return results.

I actually assumed the Perl bindings had an external function to spawn a 
database connection using the determined credentials, rather than 
require the user import DBI and create their own connection.

The Python bindings are going to be a bit different.  The DBData and 
DBDataWrite classes auto-configure themselves against the database 
tables.  Access to the channel and dtv_multiplex tables could be 
performed simply with:

from MythTV import DBData
class Channel( DBData):
     pass
class DTV_Multiplex( DBData ):
     pass
chan = Channel(<chanid>)
mplex = DTV_Multiplex(<mplexid>)

Fields are accessible through attributes or dictionary keywords.  If the 
classes are sub-classed from DBDataWrite, the update() and create() 
methods allow manipulation of existing entries and creation of new 
ones.  Everything must still be edited manually, but you don't have to 
write the MySQL statements yourself.


More information about the mythtv-users mailing list