pysqlite throwing exception?

Discussion in 'Python' started by william tanksley, Sep 5, 2009.

  1. I'm trying to modify an app I wrote a few months ago, but now it dies
    on startup (it worked before). The app loads the SQLite Media Monkey
    database, and crashes on its first query (when I try to get the number
    of podcasts). At the end of this post is a reduced version of the
    problem (which produces the same error).

    Oh, this is Python 2.5 on Windows.

    The following is the traceback for the reduced version:

    Traceback (most recent call last):
    File "C:\projects\podcasts\podstrand-mm\temp.py", line 16, in
    <module>
    cursor.execute("select count(*) as count from songs")
    OperationalError: malformed database schema - near "VIRTUAL": syntax
    error

    It's the same error I get while running this code in context.

    The major change is that I upgraded version of MediaMonkey, and I'd
    think that might cause problems-- although all of my non-Python SQLite
    support apps have no problem (including running the same query).

    Unfortunately, if pysqlite's been upgraded, I can't find it --
    pysqlite.org has been down the past 2 days.

    -Wm
    ------------

    import os
    import sqlite3

    # Find the mediamonkey database.
    conn = sqlite3.connect(
    os.path.join(os.environ['USERPROFILE'],
    'Local Settings',
    'Application Data',
    'MediaMonkey',
    'MM.DB')
    )
    conn.row_factory = sqlite3.Row # provide named columns in results
    # Ask mediamonkey for its data.
    cursor = conn.cursor()
    # Get the total number of songs.
    cursor.execute("select count(*) as count from songs")
    track_estimate = cursor.fetchall()[0]['count']
    william tanksley, Sep 5, 2009
    #1
    1. Advertising

  2. william tanksley

    MRAB Guest

    william tanksley wrote:
    > I'm trying to modify an app I wrote a few months ago, but now it dies
    > on startup (it worked before). The app loads the SQLite Media Monkey
    > database, and crashes on its first query (when I try to get the number
    > of podcasts). At the end of this post is a reduced version of the
    > problem (which produces the same error).
    >
    > Oh, this is Python 2.5 on Windows.
    >
    > The following is the traceback for the reduced version:
    >
    > Traceback (most recent call last):
    > File "C:\projects\podcasts\podstrand-mm\temp.py", line 16, in
    > <module>
    > cursor.execute("select count(*) as count from songs")
    > OperationalError: malformed database schema - near "VIRTUAL": syntax
    > error
    >
    > It's the same error I get while running this code in context.
    >
    > The major change is that I upgraded version of MediaMonkey, and I'd
    > think that might cause problems-- although all of my non-Python SQLite
    > support apps have no problem (including running the same query).
    >
    > Unfortunately, if pysqlite's been upgraded, I can't find it --
    > pysqlite.org has been down the past 2 days.
    >
    > -Wm
    > ------------
    >
    > import os
    > import sqlite3
    >
    > # Find the mediamonkey database.
    > conn = sqlite3.connect(
    > os.path.join(os.environ['USERPROFILE'],
    > 'Local Settings',
    > 'Application Data',
    > 'MediaMonkey',
    > 'MM.DB')
    > )
    > conn.row_factory = sqlite3.Row # provide named columns in results
    > # Ask mediamonkey for its data.
    > cursor = conn.cursor()
    > # Get the total number of songs.
    > cursor.execute("select count(*) as count from songs")
    > track_estimate = cursor.fetchall()[0]['count']
    >

    I wonder whether it's complaining about the "as count" part because
    "count" is the name of a function, although you do say that the same
    query works elsewhere.
    MRAB, Sep 5, 2009
    #2
    1. Advertising

  3. william tanksley <> wrote:
    > Oh, this is Python 2.5 on Windows.


    New result: this works on Python 2.6. Obviously the SQLite format
    changed between the two runs.

    I'll call this "problem solved"; my app appears to run now.

    -Wm
    william tanksley, Sep 5, 2009
    #3
  4. MRAB <> wrote:
    > I wonder whether it's complaining about the "as count" part because
    > "count" is the name of a function, although you do say that the same
    > query works elsewhere.


    Hey, good catch. Thanks; I'll change that. (It wasn't the problem, but
    no doubt someday it could be.)

    -Wm
    william tanksley, Sep 5, 2009
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. KJ
    Replies:
    5
    Views:
    373
    John Saunders
    Jul 25, 2003
  2. VincentWong
    Replies:
    1
    Views:
    549
    VincentWong
    Dec 29, 2003
  3. =?Utf-8?B?VGVycnk=?=
    Replies:
    4
    Views:
    5,977
    =?Utf-8?B?VGVycnk=?=
    Jan 13, 2005
  4. F. GEIGER
    Replies:
    2
    Views:
    526
    F. GEIGER
    May 21, 2005
  5. Gerhard Häring
    Replies:
    3
    Views:
    363
    Gerhard Häring
    Mar 13, 2008
Loading...

Share This Page