0

I'm making a sqlite3 db and in that, I have a static method that shows all the tables present in the sqlite3 file, but for that file to access the cursor object it needs the self.conn.cur, and if make the cur a global var all the other methods have to be changed so can I use the self arg in the static method? Pls Help. Thanks in advance.

1 Answer 1

1

No, a static method will not get any reference to self - self is the object the method is being invoked on, and in a static method, there is no object. If the method isn't static - i.e. it requires an object with a connection set, don't define it as static and call it on an object instead.

Another option is to call the static method and provide the connection as an argument. That allows the calling code to determine which connection should be used to retrieve information when called.

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.