Commits

Thomas Waldmann committed 1a2c41e

sqla store: use same method as sqlite store to append ::tablename, fix tests/docs

Comments (0)

Files changed (3)

MoinMoin/storage/stores/_tests/test_sqla.py

 
 @pytest.mark.multi(Store=[BytesStore, FileStore])
 def test_from_uri(tmpdir, Store):
-    store = Store.from_uri("sqlite://%s/test_base" % tmpdir)
-    assert store.db_uri == "sqlite://%s/test_base" % tmpdir
+    store = Store.from_uri("sqlite://%s::test_base" % tmpdir)
+    assert store.db_uri == "sqlite://%s" % tmpdir
     assert store.table_name == "test_base"

MoinMoin/storage/stores/sqla.py

         :param cls: Class to create
         :param uri: The database uri that we pass on to SQLAlchemy.
         """
-
-        params = [uri]
-        if '/' in uri.rsplit("//")[-1]:
-            table_name = uri.rsplit("/")[-1]
-            params.append(table_name)
+        params = uri.split("::") # using "::" to support windows pathnames that
+                                 # may include ":" after the drive letter.
         return cls(*params)
 
     def __init__(self, db_uri=None, table_name='store', verbose=False):

docs/admin/configure.rst

 Features:
 
 * stores data into an (SQL) database / table
+* can either use 1 database per store or 1 table per store (you need to
+  give different table names then)
 * uses slqalchemy (without the ORM) for database abstraction
 * supports multiple types of databases. For example:
  
 
 `uri` for `create_simple_mapping` looks like e.g.::
 
-    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s.db
-    stores:sqla:mysql://myuser:mypassword@localhost/mywiki_%(nsname)s
-    stores:sqla:postgres://myuser:mypassword@localhost/mywiki_%(nsname)s
+    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s_%(kind).db
+    stores:sqla:sqlite:////srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s
+    stores:sqla:mysql://myuser:mypassword@localhost/mywiki_%(nsname)s::%(kind)s
+    stores:sqla:postgres://myuser:mypassword@localhost/mywiki_%(nsname)s::%(kind)s
 
-Please see the sqlalchemy docs about the part after `sqla:`.
+The uri part after "sqla:" is like::
+
+    DBURI::TABLENAME
+
+Please see the sqlalchemy docs about the DBURI part.
 
 Grant 'myuser' (his password: 'mypassword') full access to these databases.
 
  
 `uri` for `create_simple_mapping` looks like e.g.::
 
-    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db
-    stores:sqlite:/srv/mywiki/data/mywiki.db::%(nsname)s
-    stores:sqlite:/srv/mywiki/data/mywiki.db::%(nsname)s::1
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s_%(kind)s.db
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s
+    stores:sqlite:/srv/mywiki/data/mywiki_%(nsname)s.db::%(kind)s::1
 
 The uri part after "sqlite:" is like::