Repository: encode/databases

Issue:
How to specify SQLite database fullpath as database URL
When I specify an absolute path of SQLite database file as database url as below, aiosqlite cannot open the database file. (on MacOS)
When I use a relative path like `sqlite:///example.db`, it works fine.
How could I specify the absolute path?

```
database = databases.Database('sqlite:////Users/otsuka/path/to/example.db')
await database.connect()

await database.fetch_all('select * from users')

.venv/lib/python3.7/site-packages/aiosqlite/core.py in connector()
    300             loc = str(database)
    301 
--> 302         return sqlite3.connect(loc, **kwargs)
    303 
    304     return Connection(connector, loop)

OperationalError: unable to open database file
```


Discussion:

Patch:
diff --git a/databases/core.py b/databases/core.py
index 9034e5f..b8da05e 100644
--- a/databases/core.py
+++ b/databases/core.py
@@ -362,7 +362,10 @@ class DatabaseURL:
 
     @property
     def database(self) -> str:
-        return self.components.path.lstrip("/")
+        path = self.components.path
+        if path.startswith("/"):
+            path = path[1:]
+        return path
 
     @property
     def options(self) -> dict:


Test patch:
diff --git a/tests/test_database_url.py b/tests/test_database_url.py
index 6324f3a..f3a63db 100644
--- a/tests/test_database_url.py
+++ b/tests/test_database_url.py
@@ -51,3 +51,9 @@ def test_replace_database_url_components():
     new = u.replace(database="test_" + u.database)
     assert new.database == "test_mydatabase"
     assert str(new) == "sqlite:///test_mydatabase"
+
+    u = DatabaseURL("sqlite:////absolute/path")
+    assert u.database == "/absolute/path"
+    new = u.replace(database=u.database + "_test")
+    assert new.database == "/absolute/path_test"
+    assert str(new) == "sqlite:////absolute/path_test"
diff --git a/tests/test_importer.py b/tests/test_importer.py
index ed3f894..832e197 100644
--- a/tests/test_importer.py
+++ b/tests/test_importer.py
@@ -4,28 +4,28 @@ from databases.importer import ImportFromStringError, import_from_string
 
 
 def test_invalid_format():
-    with pytest.raises(ImportFromStringError) as exc:
+    with pytest.raises(ImportFromStringError) as exc_info:
         import_from_string("example:")
     expected = 'Import string "example:" must be in format "<module>:<attribute>".'
-    assert expected in str(exc)
+    assert expected in str(exc_info.value)
 
 
 def test_invalid_module():
-    with pytest.raises(ImportFromStringError) as exc:
+    with pytest.raises(ImportFromStringError) as exc_info:
         import_from_string("module_does_not_exist:myattr")
     expected = 'Could not import module "module_does_not_exist".'
-    assert expected in str(exc)
+    assert expected in str(exc_info.value)
 
 
 def test_invalid_attr():
-    with pytest.raises(ImportFromStringError) as exc:
+    with pytest.raises(ImportFromStringError) as exc_info:
         import_from_string("tempfile:attr_does_not_exist")
     expected = 'Attribute "attr_does_not_exist" not found in module "tempfile".'
-    assert expected in str(exc)
+    assert expected in str(exc_info.value)
 
 
 def test_internal_import_error():
-    with pytest.raises(ImportError) as exc:
+    with pytest.raises(ImportError):
         import_from_string("tests.importer.raise_import_error:myattr")