[mythtv-users] Converting scripts to not use the database directly

Michael T. Dean mtdean at thirdcontact.com
Mon Nov 3 16:22:43 UTC 2014


On 11/03/2014 03:13 AM, Simon Hobson wrote:
> Bill Meek wrote:
>
>> If user's contributed libraries, then the original task of setting visible
>> to false would look like this (in Python):
>>
>>     import Channel
>>     Host='someHostName'
>>     for chanid in '1021', '1091', etc.
>>         channelDict = Channel.GetChannelInfo(host=Host, chanid=chanid)
>>         channelDict['Visible'] = 'false'
>>         Channel.UpdateDBChannel(host=Host, rdict=channelDict)
>>
>> I'd say that's a very reasonable substitute for the SQL, and much safer, Once
>> the key issue is resolved (easily handled in the Channel module for now.)
>
> I disagree.
> Yes it's a substitute, and probably workable, but from what I'm seeing it looks like a very inferior substitute.
>
> It looks like a simple statement :
>> update channel set channum=channum+10000 where channum<  1000 and not channum between 700 and 799
> becomes a loop where I've got to work through all the channels, perform a test, and update some of them.

And we all know just how long a modern computer takes to loop through 
hundreds of things (or even a couple thousand for some users!!!).  Yes, 
this is simply unworkable.  I want my microseconds back!

> Then each statement of the form :
>> update channel set visible=1,channum=1,xmltvid="north-west.bbc1.bbc.co.uk" where callsign="BBC ONE N West"
> alos becomes several statements - in practice I'll need to loop round, but bear in mind I have different settings for different channels, eg :
>> update channel set visible=1,channum=27,useonairguide=1,xmltvid="freeview.quest.discoveryeurope.com" where callsign="QUEST"
> SO a very simple list of statements becomes a significant coding exercise.

All that is simply a user-interface issue.  Make a script better suited 
to exactly what you want and then it will be even easier than your 
SQL--and will survive changes over time.

That said, this is not a knock against Bill scripts.  What Bill is doing 
is good--to make good purpose-specific scripts, we first need nice, 
generic code.

Mike


More information about the mythtv-users mailing list