why my cur.executescript can not run?
length power
elearn2014 at gmail.com
Wed Apr 23 07:23:42 EDT 2014
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?
please download the attachment and save it in
g:\\workspace\\data\\Cinfo.sqlite to test my code,then you can draw
the conclusion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140423/8529f8bc/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cinfo.zip
Type: application/zip
Size: 662632 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20140423/8529f8bc/attachment.zip>
More information about the Python-list
mailing list