0

I have a table in sql server 2008 with some 11-columns and 11-rows

I have function where I fetch data from the data using fetchall() like:

def main():
   cursor.execute("select * from [dbo].[mytable] where isActive=1 and IsDownloaded=0")
   result = cursor.fetchall()
   for row in result:
       ConfigId =row[0]
       pattern = row[1]
       ....

Here I can fetch all rows with this FOR loop,where as I want to use this same table in two programs to fetch only particular rows

fetching rows 1st-6th and last 11th row in one program and remaining 4 rows in another in other program.

How can I do that?

1 Answer 1

1

See if you can do something like this:

result = cursor.fetchall()
prog1 = result[0:6]
prog1.extend(result[12])
prog2 = result[6:11]

Now prog1 will have rows from 1 to 6 and 11. prog2 will have remaining 4.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.