jazzband / dj-database-url

Use Database URLs in your Django Application.
https://pypi.org/project/dj-database-url/
BSD 3-Clause "New" or "Revised" License
1.49k stars 205 forks source link

Support for named :memory: urls? #97

Closed tony closed 5 years ago

tony commented 6 years ago

Some lore / background on this: https://www.sqlite.org/inmemorydb.html

https://github.com/django/django/commit/3543fec3b739864c52de0a116dde3b0e5e885799

https://www.sqlite.org/inmemorydb.html

python 3.6.3

dj-database-url 0.4.2

django 1.11.8

3.19.3 2017-06-27 16:48:08 2b0954060fe10d6de6d479287dd88890f1bef6cc1beca11bc6cdb79f72e2377b

assuming

            'secondary': dj_database_url.config(
                env='SECONDARY_DATABASE',
                default='sqlite://testdb?mode=memory',
            ),
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 65, in applied_migrations
    self.ensure_schema()
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 52, in ensure_schema
    if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 254, in cursor
    return self._cursor()
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 229, in _cursor
    self.ensure_connection()
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection
    self.connect()
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/backends/base/base.py", line 189, in connect
    self.connection = self.get_new_connection(conn_params)
  File "/Users/me/work/python/django-polymorphic/.venv/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 198, in get_new_connection
    conn = Database.connect(**conn_params)
TypeError: keywords must be strings

Trying to debug an unrelated issue at https://github.com/django-polymorphic/django-polymorphic/pull/318#issuecomment-349707486 where we use dj-database-url in tests and I want to rule out if two :memory: sqlite connections could be causing stuff to fizzle or not.

jacobian commented 5 years ago

I think this is effectively the same as #117 - if we can find a good syntax for it I'm fine with it, but until then I'm going to close.