Moode Forum
Database table error - Printable Version

+- Moode Forum (https://moodeaudio.org/forum)
+-- Forum: moOde audio player (https://moodeaudio.org/forum/forumdisplay.php?fid=3)
+--- Forum: Support (https://moodeaudio.org/forum/forumdisplay.php?fid=7)
+--- Thread: Database table error (/showthread.php?tid=200)



Database table error - Max Schmeling - 05-21-2018

After upgrading to Moode 4.1 I get an database error when I try to access the moode-sqlite3.db

To connect to the database with Python,  I do this:

Code:
try:
        con = SQLite3.connect('/var/local/www/db/moode-sqlite3.db')    
except SQLite3.Error, e:
        if Debug: print "Error %s:" % e.args[0]
        sys.exit(1)
Which works fine.

To figure out if Airplay is active, I used to do this:

Code:
# Airplay state check
def IsAirplayOn():
    
    global ButtonOverride
    
    AirplayOn = False
    try:
        cur = con.cursor()    
        cur.execute('select value from cfg_engine where param=\'airplayactv\'')
        data = cur.fetchone()[0]    
        if (Debug): print "SQL = %s" % data
        if data == "1":
            AirplayOn = True

    except SQLite3.Error, e:
        if (Debug): print "Error %s:" % e.args[0]

    if ButtonOverride:
        AirplayOn = False
    
    if Debug: print "Returning IsAirplayOn = {0}".format(AirplayOn)
    return AirplayOn

But this gives me an error about the table cfg_engine, which seems to have been changed.

Does anybody know which table and parameter, I should be querying, or just how to find out if Airplay is active?


RE: Database table error - TheOldPresbyope - 05-21-2018

(05-21-2018, 01:49 PM)Max Schmeling Wrote: After upgrading to Moode 4.1 I get an database error when I try to access the moode-sqlite3.db

To connect to the database with Python,  I do this:

Code:
try:
        con = SQLite3.connect('/var/local/www/db/moode-sqlite3.db')    
except SQLite3.Error, e:
        if Debug: print "Error %s:" % e.args[0]
        sys.exit(1)
Which works fine.

To figure out if Airplay is active, I used to do this:

Code:
# Airplay state check
def IsAirplayOn():
    
    global ButtonOverride
    
    AirplayOn = False
    try:
        cur = con.cursor()    
        cur.execute('select value from cfg_engine where param=\'airplayactv\'')
        data = cur.fetchone()[0]    
        if (Debug): print "SQL = %s" % data
        if data == "1":
            AirplayOn = True

    except SQLite3.Error, e:
        if (Debug): print "Error %s:" % e.args[0]

    if ButtonOverride:
        AirplayOn = False
    
    if Debug: print "Returning IsAirplayOn = {0}".format(AirplayOn)
    return AirplayOn

But this gives me an error about the table cfg_engine, which seems to have been changed.

Does anybody know which table and parameter, I should be querying, or just how to find out if Airplay is active?

Hi, Max.

the sqlite3 command .tables will list the tables. You're now looking for cfg_system, in which param 50="airplayactv".

Regards,
Kent


RE: Database table error - Max Schmeling - 05-21-2018

(05-21-2018, 02:04 PM)TheOldPresbyope Wrote:
(05-21-2018, 01:49 PM)Max Schmeling Wrote: After upgrading to Moode 4.1 I get an database error when I try to access the moode-sqlite3.db

To connect to the database with Python,  I do this:

Code:
try:
        con = SQLite3.connect('/var/local/www/db/moode-sqlite3.db')    
except SQLite3.Error, e:
        if Debug: print "Error %s:" % e.args[0]
        sys.exit(1)
Which works fine.

To figure out if Airplay is active, I used to do this:

Code:
# Airplay state check
def IsAirplayOn():
    
    global ButtonOverride
    
    AirplayOn = False
    try:
        cur = con.cursor()    
        cur.execute('select value from cfg_engine where param=\'airplayactv\'')
        data = cur.fetchone()[0]    
        if (Debug): print "SQL = %s" % data
        if data == "1":
            AirplayOn = True

    except SQLite3.Error, e:
        if (Debug): print "Error %s:" % e.args[0]

    if ButtonOverride:
        AirplayOn = False
    
    if Debug: print "Returning IsAirplayOn = {0}".format(AirplayOn)
    return AirplayOn

But this gives me an error about the table cfg_engine, which seems to have been changed.

Does anybody know which table and parameter, I should be querying, or just how to find out if Airplay is active?

Hi, Max.

the sqlite3 command .tables will list the tables. You're now looking for cfg_system, in which param 50="airplayactv".

Regards,
Kent

I'll try that. Thanks Smile Smile