Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #70558

Re: why my cur.executescript can not run?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:not': 0.03; 'assignment': 0.07; 'get.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:skip:c 10': 0.09; 'message- id:@4ax.com': 0.16; 'quoted': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'retrieving': 0.16; 'skip:> 20': 0.16; 'statement.': 0.16; 'subject:run': 0.16; 'attach': 0.16; 'wed,': 0.18; 'producing': 0.19; "skip:' 30": 0.19; 'seems': 0.21; 'text,': 0.24; 'url:home': 0.24; 'script': 0.25; 'header:X -Complaints-To:1': 0.27; 'statement': 0.30; 'used,': 0.33; 'third': 0.33; "i'd": 0.34; "can't": 0.35; 'transaction': 0.35; 'something': 0.35; 'but': 0.35; 'skip:> 10': 0.36; 'charset:us- ascii': 0.36; 'subject:?': 0.36; 'question,': 0.38; 'to:addr :python-list': 0.38; 'subject:can': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'length': 0.61; 'results': 0.69; 'power': 0.76; 'why?': 0.91; 'received:108': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: why my cur.executescript can not run?
Date Wed, 23 Apr 2014 20:05:41 -0400
Organization IISS Elusive Unicorn
References <CAOmh461B32OV9+-rUQUYz9iMF8bjt_dxUzv4P7tSrP+yjS3reg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-79-222-171.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.9476.1398297951.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1398297951 news.xs4all.nl 2829 [2001:888:2000:d::a6]:47800
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:70558

Show key headers only | View raw


On Wed, 23 Apr 2014 19:23:42 +0800, length power <elearn2014@gmail.com>
declaimed the following:

>When cur.execute be used, i get right output.
>
>import sqlite3
>con=sqlite3.connect(":memory:")
>cur=con.cursor()
>sql1="attach database 'g:\\workspace\\data\\Cinfo.sqlite' as Cinfo;"
>sql2="select * from Cinfo.ipo;"
>cur.execute(sql1)
>cur.execute(sql2)
>con.commit()
>x=cur.fetchall()print(x)
>
>When i change it into cur.executescript, nothing can get.
>
>import sqlite3
>con=sqlite3.connect(":memory:")
>cur=con.cursor()
>sql_script="""
>attach database 'g:\\workspace\\data\\Cinfo.sqlite' as Cinfo;
>select * from Cinfo.ipo;"""
>cur.executescript(sql_script)
>con.commit()
>x=cur.fetchall()print(x)
>
>I want to know why?
>

	Can't answer your main question, but ... I'd put the .commit() AFTER
the .fetchall() -- since I don't think the DB-API promises results to be
available after a transaction commit().

	ALSO -- note that in the quoted text, your "print(x)" seems to have
been appended to the prior assignment statement -- so something is flaky
with your line endings.

	A third hypothesis: EACH statement in your script may be producing a
result-set, and the .fetchall is only retrieving the (empty) result-set
from the ATTACH statement.
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: why my cur.executescript can not run? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-04-23 20:05 -0400

csiph-web