Skip to content
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

Do not require SQL URIs to be prefixed with SQLAlchemy driver #810

Merged
merged 9 commits into from
Nov 5, 2024

Conversation

danielballan
Copy link
Member

@danielballan danielballan commented Nov 4, 2024

In many places, we require SQL database URIs to include the "driver" like:

postgresql+asyncpg://user:password@localhost:5432/database
sqlite+aiosqlite:////test.db

This is a SQLAlchemy idiom that is not standard for SQL database URIs generally. In this PR, Tiled now accepts standard URIs like:

postgresql://user:password@localhost:5432/database
sqlite:////test.db

It still accepts URIs with a driver specified.

These commits are cherry-picked from #779 into a separate PR.

Checklist

  • Add a Changelog entry
  • Add the ticket number which this PR closes to the comment section

if not SCHEME_PATTERN.match(str(uri)):
# Interpret URI as filepath.
uri = f"sqlite+aiosqlite:///{Path(uri)}"
scheme, rest = uri.split(":", 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you not use urllib to parse because in theory this could be URI that's not a URL?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember reaching for urllib first. I believe the issue was that certain SQLite URIs do not round-trip quite right.

@danielballan danielballan merged commit e52bab3 into bluesky:main Nov 5, 2024
8 checks passed
@danielballan danielballan deleted the sql-uris branch November 5, 2024 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants