-
Notifications
You must be signed in to change notification settings - Fork 609
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(sqlite): defer db connection until needed #3127
Changes from all commits
43fe224
157fd86
b36d41b
e94f511
7d68a5d
75406cc
7d32cf5
db05cc5
405dc85
d463c0d
3107c6a
c474003
4de2ded
3603e10
404b034
ab70fcf
02891dc
eca2830
5ff220e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,7 @@ class BaseFileBackend(BaseBackend): | |
|
||
database_class = FileDatabase | ||
|
||
def connect(self, path): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you cannot rename any of these methods as they r public There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, I'm proposing an API change. (See the toplevel comment I just posted.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback The top level API here isn't changing. Every backend still has the same There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure it is. this is leaking the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, do_connect would be required for new backends or those that want to upgrade. I don't think I see the problem, we'd release a new major version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jreback Unfortunately the thing I need is to detach the object construction from the db connection, so I can copy Expr from any arbitrary db table and have them 'just work'. I think it's generally good practice to separate these two anyway--in my experience the constructor/factory should set initial state and not "do" anything, so it can't fail/raise which makes things more complicated for everyone. |
||
def do_connect(self, path): | ||
"""Create a Client for use with Ibis | ||
|
||
Parameters | ||
|
@@ -67,10 +67,8 @@ def connect(self, path): | |
------- | ||
Backend | ||
""" | ||
new_backend = self.__class__() | ||
new_backend.path = new_backend.root = Path(path) | ||
new_backend.dictionary = {} | ||
return new_backend | ||
self.path = self.root = Path(path) | ||
self.dictionary = {} | ||
|
||
@property | ||
def version(self) -> str: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we preserve this for backwards compatibilty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look a few lines above this, it's still there, so you can continue to use
connect()
like you always have.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahh fi that's the case, then just document connect & db_connect a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'm not clear on what's missing, or where this documentation would go. Backends need to override the abstractmethod
do_connect
, but that's virtually identical to what they had to do previously withconnect
(as shown in this comment in the PR). What else do you need?