Fixed #12118 - Added ability to share sqlite in-memory database in threads.

Sqlite3 with version >=3.7.13 can share in-memory database between threads.
Built-in sqlite module of python2 comes without ability to specify in-memory database name as URI, but since python3.4 can do this,
So, need to use database name as URI to prevent fails in tests.
I'm returning URI manually, if database name is specified as `:memory:` in settings to give ability to use shared cache without specifying it manually (people will have this after update).