469,943 Members | 2,532 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

sqlite3 views, if not exists clause

Hi,
I'm running into a problem when trying to create a view in my sqlite
database in python. I think its a bug in the sqlite3 api that comes with
python 2.5.

This works as expected:
conn = sqlite3.connect(':memory:')
conn.execute("create table foo (a int,b int)")
conn.execute('create view bar as select * from foo')

This fails as expected:
conn = sqlite3.connect(':memory:')
conn.execute("create table foo (a int,b int)")
conn.execute('create view bar as select * from foo')
conn.execute('create view bar as select * from foo')
with exception "sqlite3.OperationalError: table bar already exists".
Weird that it fails with TABLE bar already exists, but this is the message
that sqlite actually returns so it is not python's fault.

THIS DOES NOT WORK, but it should!
conn = sqlite3.connect(':memory:')
conn.execute("create table foo (a int,b int)")
conn.execute('create view if not exists bar as select * from foo')
it fails with exception "sqlite3.OperationalError: near "not": syntax error"

Can anyone confirm, or pass this on to the appropriate person?
Thanks!
Josh

Nov 14 '06 #1
2 4743
"Josh" wrote:
THIS DOES NOT WORK, but it should!
Python 2.5 was released on September 19th, 2006, and support for CREATE
VIEW IF NOT EXISTS was added to sqlite on October 9th, 2006:

http://www.sqlite.org/changes.html

</F>

Nov 14 '06 #2
Fredrik Lundh wrote:
"Josh" wrote:
>THIS DOES NOT WORK, but it should!

Python 2.5 was released on September 19th, 2006, and support for CREATE
VIEW IF NOT EXISTS was added to sqlite on October 9th, 2006:
So? "from __future__ import ..." should have supported this! <:o)

--
Roberto Bonvallet
Nov 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Jim Devenish | last post: by
66 posts views Thread by mensanator | last post: by
38 posts views Thread by John Salerno | last post: by
2 posts views Thread by Victor Lin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.