Skip to content

Commit

Permalink
Remove python 2.6-specific workaround in db_url.
Browse files Browse the repository at this point in the history
Replaces #2915
  • Loading branch information
coleifer committed Jul 12, 2024
1 parent 0b16576 commit 7306521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 3 additions & 6 deletions playhouse/db_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,10 @@ def parseresult_to_dict(parsed, unquote_password=False):

# urlparse in python 2.6 is broken so query will be empty and instead
# appended to path complete with '?'
path_parts = parsed.path[1:].split('?')
try:
query = path_parts[1]
except IndexError:
query = parsed.query
path = parsed.path[1:] # Ignore leading '/'.
query = parsed.query

connect_kwargs = {'database': path_parts[0]}
connect_kwargs = {'database': path}
if parsed.username:
connect_kwargs['user'] = parsed.username
if parsed.password:
Expand Down
6 changes: 6 additions & 0 deletions tests/db_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ def test_db_url(self):
self.assertTrue(isinstance(db, SqliteDatabase))
self.assertEqual(db.database, ':memory:')

db = connect('sqlite:///test.db?p1=1?a&p2=22&p3=xyz')
self.assertTrue(isinstance(db, SqliteDatabase))
self.assertEqual(db.database, 'test.db')
self.assertEqual(db.connect_params, {
'p1': '1?a', 'p2': 22, 'p3': 'xyz'})

def test_bad_scheme(self):
def _test_scheme():
connect('missing:///')
Expand Down

0 comments on commit 7306521

Please sign in to comment.