-
Notifications
You must be signed in to change notification settings - Fork 31
Description
Looking at connect()
function, there are several things which are raising questions.
project arg:
project
is set as an optional arg:
def connect(project=None, instance=None, database=None, credentials_uri=None, user_agent=None): |
python-spanner-django/spanner_dbapi/__init__.py
Lines 51 to 52 in 11222db
if not project: | |
raise Error("'project' is required.") |
google.auth.default()
function to designate the project id from the environment. With this, I'd propose to drop this check and use project
arg in the way of the original Spanner client.
instance and database args:
They are optional by definition, but in fact both are required. Probably, they should become required in definition (the function signature will be connect(instance, database, project=None, credentials_uri=None, user_agent=None):
), so these checks could be dropped:
python-spanner-django/spanner_dbapi/__init__.py
Lines 53 to 56 in 11222db
if not instance: | |
raise Error("'instance' is required.") | |
if not database: | |
raise Error("'database' is required.") |
credentials_uri arg:
This arg looks divergent from how the original Spanner client is dealing with credentials:
https://github.com/googleapis/python-spanner/blob/b6b0348f5870f55c88b3cae44e229325fd755b26/google/cloud/spanner_v1/client.py#L123-L129
I'd propose to change this arg to use google.auth.credentials.Credentials
class as it's done in the original Spanner client.