【发布时间】:2014-04-19 17:34:43
【问题描述】:
代码如下,顺便说一下,我使用的数据库是teradata,在windows 7操作系统和python 2.7版中。
import pyodbc
cnxn = pyodbc.connect('DSN=thisIsAbsolutelyCorrect;UID=cannottellyou;PWD=iamsosorry')
cursor1 = cnxn.cursor()
cursor1=cursor1.execute(
################## OR put your SQL dirctly between here ################
'''
create volatile table table1
(
field1 integer
,field2 integer
)on commit preserve rows;
--insert into table1
--values(12,13);
--select * from table1;
''')
######################### and here ########################
cnxn.commit()
for row in cursor1:
print row
raw_input()
但我得到这样的错误:
Traceback (most recent call last):
File "C:\Users\issuser\Desktop\py\test.py", line 25, in <module>
for row in cursor1:
ProgrammingError: No results. Previous SQL was not a query.
我该如何解决这个错误?
【问题讨论】:
-
您要打印什么?插入和选择语句被注释掉。
标签: python sql teradata pyodbc