0

I am having a script which makes a db connection and pereform some select operation.accroding to the fetch data i am calling different functions which also perform db operations.How can i pass db connection to the functions which are being called as i donot want to make new connection

6
  • 1
    -1: being more specific about the problem might help Commented Jun 1, 2009 at 10:11
  • 1
    Not really fair to downvote, users come from all over the world. Sounds as though you need to express your data connection as a variable in your class, then you can pass it in the arguments of the methods you need to call. Not a python man myself, so I'll leav it to someone who knows. Commented Jun 1, 2009 at 10:17
  • 1
    A DB connection can be passed as an argument to a function. What specific problem are you having? Please provide sample code and an error message that shows what is not working. Commented Jun 1, 2009 at 10:31
  • 2
    @Mark Dickinson: no sample code and no error message IS a pretty good reason to downvote, IMO. Commented Jun 1, 2009 at 10:32
  • 1
    @kender: Nice hypothesis. Hopefully, the question will be updated to include facts. Commented Jun 1, 2009 at 13:01

1 Answer 1

2

Why to pass connection itself? Maybe build a class that handles all the DB-operation and just pass this class' instance around, calling it's methods to perform selects, inserts and all that DB-specific code?

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.