My favorites | Sign in
Project Home Downloads Wiki
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 331: Issue inserting records - ProgrammingError: No results. Previous SQL was not a query.
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by oli82u...@gmail.com, Jul 11, 2013
What steps will reproduce the problem?

Have tried both with a stored procedure and standard insert but they dont appear to work. Please let me know what I am doing wrong here.

from urllib import urlopen
from bs4 import BeautifulSoup
import re
import pyodbc

noCount = """
SET NOCOUNT ON;
"""

cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=Z930-108A;DATABASE=test;UID=user;PWD=friday')
cursor = cnxn.cursor()
for row in cursor.execute(noCount + " select ABSTRACT_ID, ISBN from abstract where ISBN is not null;"):
    ABSTRACT_ID = row.ABSTRACT_ID
    ISBN = r"https://www.worldcat.org/ISBN/" + row.ISBN
    print ISBN
    webpage = urlopen(ISBN).read()
    soup2 = BeautifulSoup(webpage)
    DETAIL = soup2.title
#   EXESTRING = " UPDATE ABSTRACT SET TAG = N'" + str(DETAIL) + "' WHERE ABSTRACT_ID = " + str(ABSTRACT_ID)
    EXESTRING = " EXEC DBO.sp1 " + str(ABSTRACT_ID) + ",N'" + str(DETAIL) +"'"
    print EXESTRING
    cursor.execute(EXESTRING)
    print cursor.rowcount, 'products updated'
    cnxn.commit()
cnxn.close()


Stored Procedure looks like this

USE [test]
GO
/****** Object:  StoredProcedure [dbo].[sp1]    Script Date: 11/07/2013 20:16:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER PROCEDURE [dbo].[sp1]
	-- Add the parameters for the stored procedure here
@ABSTRACT_ID INT,
@TAG NVARCHAR(MAX)
AS
BEGIN

	SET NOCOUNT ON;

UPDATE ABSTRACT 
SET TAG = @TAG WHERE ABSTRACT_ID = @ABSTRACT_ID


END




What is the expected output? What do you see instead?

--- entry should be inserted and move onto the next one


What version of the product are you using? On what operating system?

Windows 8 python 2.7.5


Please provide any additional information below.

Any help would be great.

Thanks

Powered by Google Project Hosting