Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   pysqlite throwing exception? (http://www.velocityreviews.com/forums/t697268-pysqlite-throwing-exception.html)

william tanksley 09-05-2009 08:40 PM

pysqlite throwing exception?
 
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']


MRAB 09-05-2009 09:11 PM

Re: pysqlite throwing exception?
 
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.

william tanksley 09-05-2009 09:36 PM

Re: pysqlite throwing exception?
 
william tanksley <wtanksle...@gmail.com> 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 09-05-2009 09:37 PM

Re: pysqlite throwing exception?
 
MRAB <pyt...@mrabarnett.plus.com> 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


All times are GMT. The time now is 05:07 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.