By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

sqlite3 views, if not exists clause

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
"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

P: n/a
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.