changeset 1308:166fecfb17ad

fix sqlite database path issue on windows, use :: as separator (also added docs) - fixes #168
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sat, 24 Mar 2012 22:20:04 +0100
parents cfef35e4c9eb
children 6667e2a0c58e
files MoinMoin/storage/stores/_tests/test_sqlite.py MoinMoin/storage/stores/sqlite.py docs/admin/configure.rst
diffstat 3 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/storage/stores/_tests/test_sqlite.py	Sat Mar 24 20:51:33 2012 +0100
+++ b/MoinMoin/storage/stores/_tests/test_sqlite.py	Sat Mar 24 22:20:04 2012 +0100
@@ -48,12 +48,13 @@
 
 @pytest.mark.multi(Store=[BytesStore, FileStore])
 def test_from_uri(tmpdir, Store):
-    store = Store.from_uri("%s:test_table:0" % tmpdir)
+    store = Store.from_uri("%s::test_table::0" % tmpdir)
     assert store.db_name == tmpdir
     assert store.table_name == 'test_table'
     assert store.compression_level == 0
 
-    store = Store.from_uri("%s:test_table:2" % tmpdir)
+    store = Store.from_uri("%s::test_table::2" % tmpdir)
     assert store.db_name == tmpdir
     assert store.table_name == 'test_table'
     assert store.compression_level == 2
+
--- a/MoinMoin/storage/stores/sqlite.py	Sat Mar 24 20:51:33 2012 +0100
+++ b/MoinMoin/storage/stores/sqlite.py	Sat Mar 24 22:20:04 2012 +0100
@@ -32,10 +32,11 @@
 
         :param cls: Class to create
         :param uri: The URI should follow the following template
-                    db_name:table_name:compression_level
+                    db_name::table_name::compression_level
                     where table_name and compression level are optional
         """
-        params = uri.split(":")
+        params = uri.split("::") # using "::" to support windows pathnames that
+                                 # may include ":" after the drive letter.
         if len(params) == 3:
             params[2] = int(params[2])
         return cls(*params)
--- a/docs/admin/configure.rst	Sat Mar 24 20:51:33 2012 +0100
+++ b/docs/admin/configure.rst	Sat Mar 24 22:20:04 2012 +0100
@@ -1150,6 +1150,31 @@
 Grant 'myuser' (his password: 'mypassword') full access to these databases.
 
 
+sqlite store
+------------
+Features:
+
+* directly talks to sqlite, not using sqlalchemy
+* stores data into an sqlite database, which is a single file
+* can either use 1 database per store or 1 table per store (you need to
+  give different table names then)
+* can optionally compress/decompress the data using zlib (default compression
+  level is 0, which means to not compress)
+ 
+`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
+
+The uri part after "sqlite:" is like::
+
+    PATH::TABLENAME::COMPRESSION
+
+It uses "::" as separator to support windows pathes which may have ":" after
+the drive letter.
+
+
 kc store
 --------
 Features: