467,184 Members | 1,255 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,184 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
  • viewed: 4634
Share:
2 Replies
"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

2 posts views Thread by dbuchanan52@hotmail.com | last post: by
6 posts views Thread by Jim Devenish | last post: by
66 posts views Thread by mensanator@aol.com | last post: by
38 posts views Thread by John Salerno | last post: by
29 posts views Thread by dbhbarton@googlemail.com | 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.