You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 14, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on May 14, 2026. It is now read-only.
feat: set user-agent string to distinguish SQLAlchemy requests #115
Is your feature request related to a problem? Please describe.
The implementation doesn't seem to set a user-agent string to indicate that the requests are coming from SQLAlchemy.
Describe the solution you'd like
Set the user-agent in the dbapi connection.
Describe alternatives you've considered
N/A
Additional context
It seems that dbapi by default sets the DEFAULT_USER_AGENT = "django_spanner/" + VERSION. This may not be ideal.
Good question, I think it is good to distinguish between the client library and dbapi. So how about we default dbapi to something like "dbapi/" where version is the Spanner client version as they both get released in the same package?
Not everybody using this package (or python-spanner for that matter) uses Django - this library is just the SQLAlchemy dialect for Spanner and has nothing to do with Django.
@IlyaFaer I assume you'll have a PR coming to fix the default in dbapi?
@geudrik I'm a bit torn on whether to default dbapi to have python-spanner/<version> or dbapi/<version. I think ideally we'd distinguish the Python client from dbapi since they have different use cases. But I understand that it's in the same package so maybe it's confusing to distinguish it.
I'm just an internet stranger, so take my input with some salt. It's your repo after all!
If it were me, I'd ensure that the request identified the code actually using the functionality. In this case, dbapi is the lower level and should have a sane default. But since this lib is another layer up (it depends on dbapi), it's the one that's actually invested in the call.
Activity
IlyaFaer commentedon Sep 7, 2021
Pushed changes for SQLAlchemy: #116
As I see, Django already uses its own user agent (though it's hardcoded): https://github.com/googleapis/python-spanner-django/blob/4643876219e8a54feb94bf14a79f0fe2fbe3971a/django_spanner/base.py#L135
So, the only place left is the DB API itself:
https://github.com/googleapis/python-spanner/blob/48ac924672c8387e3d47da4eace00c3bdbf3baf6/google/cloud/spanner_dbapi/version.py#L19
What name it should have? It's DB API, but it lives in
google-cloud-spanner. Is it desired to divide the original client and the DB API user agents?skuruppu commentedon Sep 7, 2021
Good question, I think it is good to distinguish between the client library and dbapi. So how about we default dbapi to something like "dbapi/" where version is the Spanner client version as they both get released in the same package?
geudrik commentedon Sep 8, 2021
Not everybody using this package (or
python-spannerfor that matter) uses Django - this library is just the SQLAlchemy dialect for Spanner and has nothing to do with Django.https://github.com/googleapis/python-spanner/blob/48ac924672c8387e3d47da4eace00c3bdbf3baf6/google/cloud/spanner_dbapi/version.py#L19
This also appears to be framework agnostic - shouldn't this be set instead to the library name
python-spannerby default, allowing for an override (which we'd use from this lib)?geudrik commentedon Sep 8, 2021
Looks like I'm just late to the party, based on @IlyaFaer 's MR that's been merged
skuruppu commentedon Sep 8, 2021
@IlyaFaer I assume you'll have a PR coming to fix the default in dbapi?
@geudrik I'm a bit torn on whether to default dbapi to have
python-spanner/<version>ordbapi/<version. I think ideally we'd distinguish the Python client from dbapi since they have different use cases. But I understand that it's in the same package so maybe it's confusing to distinguish it.geudrik commentedon Sep 8, 2021
I'm just an internet stranger, so take my input with some salt. It's your repo after all!
If it were me, I'd ensure that the request identified the code actually using the functionality. In this case, dbapi is the lower level and should have a sane default. But since this lib is another layer up (it depends on dbapi), it's the one that's actually invested in the call.