From 91c985b3e876cb9cc53f7042ed88e6247b29606f Mon Sep 17 00:00:00 2001 From: Tyler Kennedy Date: Thu, 31 Jul 2014 11:07:09 -0400 Subject: [PATCH 1/8] Update database.py Inverted logic means _release_internal will always fail on a rollback. Fixed and simplified. --- dataset/persistence/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataset/persistence/database.py b/dataset/persistence/database.py index d87963a..3a5f18f 100644 --- a/dataset/persistence/database.py +++ b/dataset/persistence/database.py @@ -80,7 +80,7 @@ class Database(object): self.local.must_release = True def _release_internal(self): - if not hasattr(self.local, 'must_release') and self.local.must_release: + if getattr(self.local, 'must_release', None): self.lock.release() self.local.must_release = False From f7b7d1f9e60ba6300fc6305bf58c022b0d31a79e Mon Sep 17 00:00:00 2001 From: Tyler Kennedy Date: Thu, 31 Jul 2014 11:08:07 -0400 Subject: [PATCH 2/8] Update setup.py Bugfix version bump. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index eb0c54b..ba6ed1a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ if sys.version_info[:2] <= (2, 6): setup( name='dataset', - version='0.5.4', + version='0.5.5', description="Toolkit for Python-based data processing.", long_description="", classifiers=[ From a8b2f1ad738709fb49c5e3f9175822cc1bafa11d Mon Sep 17 00:00:00 2001 From: Chenguang Zhang Date: Thu, 7 Aug 2014 16:47:50 +0800 Subject: [PATCH 3/8] Add more instructions for engine_kwargs, to avoid DB connection timeout issues --- dataset/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dataset/__init__.py b/dataset/__init__.py index 84963a0..5c205f8 100644 --- a/dataset/__init__.py +++ b/dataset/__init__.py @@ -18,12 +18,14 @@ def connect(url=None, schema=None, reflectMetadata=True, engine_kwargs=None): If *url* is not defined it will try to use *DATABASE_URL* from environment variable. Returns an instance of :py:class:`Database `. Set *reflectMetadata* to False if you don't want the entire database schema to be pre-loaded. This significantly speeds up - connecting to large databases with lots of tables. + connecting to large databases with lots of tables. Additionally, *engine_kwargs* will be directly passed to + SQLAlchemy, e.g. set *engine_kwargs={'pool_recycle': 3600}* will avoid `DB connection timeout`_. :: db = dataset.connect('sqlite:///factbook.db') .. _SQLAlchemy Engine URL: http://docs.sqlalchemy.org/en/latest/core/engines.html#sqlalchemy.create_engine + .. _DB connection timeout: http://docs.sqlalchemy.org/en/latest/core/pooling.html#setting-pool-recycle """ if url is None: url = os.environ.get('DATABASE_URL', url) From 1bdd35ee84655a5c0197ec7ef813fce0e8b05267 Mon Sep 17 00:00:00 2001 From: Friedrich Lindenberg Date: Fri, 8 Aug 2014 10:18:27 +0200 Subject: [PATCH 4/8] fix logo link, fixes #104 --- docs/_themes/kr/sidebarlogo.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/_themes/kr/sidebarlogo.html b/docs/_themes/kr/sidebarlogo.html index 4631beb..5f088f8 100644 --- a/docs/_themes/kr/sidebarlogo.html +++ b/docs/_themes/kr/sidebarlogo.html @@ -1,4 +1,4 @@ -dataset +dataset

Because managing databases in Python should be as simple as reading and writing JSON files.

From 17bad827aee368b5658a5469b0e5860977080b31 Mon Sep 17 00:00:00 2001 From: Thomas Levine <_@thomaslevine.com> Date: Fri, 29 Aug 2014 18:12:25 +0000 Subject: [PATCH 5/8] add __contains__ --- dataset/persistence/database.py | 3 +++ test/test_persistence.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/dataset/persistence/database.py b/dataset/persistence/database.py index 3a5f18f..6261ee3 100644 --- a/dataset/persistence/database.py +++ b/dataset/persistence/database.py @@ -141,6 +141,9 @@ class Database(object): set(self.metadata.tables.keys()) | set(self._tables.keys()) ) + def __contains__(self, member): + return member in self.tables + def create_table(self, table_name, primary_id='id', primary_type='Integer'): """ Creates a new table. The new table will automatically have an `id` column diff --git a/test/test_persistence.py b/test/test_persistence.py index 6040999..c009c42 100644 --- a/test/test_persistence.py +++ b/test/test_persistence.py @@ -38,6 +38,9 @@ class DatabaseTestCase(unittest.TestCase): def test_tables(self): assert self.db.tables == ['weather'], self.db.tables + def test_contains(self): + assert 'weather' in self.db, self.db.tables + def test_create_table(self): table = self.db['foo'] assert table.table.exists() From 8d4c6ecb55eda2e51269b0cc4f334730cb61deed Mon Sep 17 00:00:00 2001 From: Andrew McNett Date: Sun, 21 Sep 2014 21:28:37 -0700 Subject: [PATCH 6/8] quickstart typo: "invocing" should be "invoking" :) --- docs/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index f4682ad..aa8a00e 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -75,7 +75,7 @@ statement:: with dataset.connect() as tx: tx['user'].insert(dict(name='John Doe', age=46, country='China')) -You can get same functionality by invocing the methods :py:meth:`begin() `, +You can get same functionality by invoking the methods :py:meth:`begin() `, :py:meth:`commit() ` and :py:meth:`rollback() ` explicitly:: From 036739589a038f945c17ed792af9d91ea14fa6f1 Mon Sep 17 00:00:00 2001 From: aniversarioperu Date: Sun, 5 Oct 2014 11:51:18 +0300 Subject: [PATCH 7/8] Fixing typo in docstring for `query` The SQLAlchemy link was pointing to a dead link. --- dataset/persistence/database.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dataset/persistence/database.py b/dataset/persistence/database.py index 6261ee3..0687681 100644 --- a/dataset/persistence/database.py +++ b/dataset/persistence/database.py @@ -256,7 +256,7 @@ class Database(object): """ Run a statement on the database directly, allowing for the execution of arbitrary read/write queries. A query can either be - a plain text string, or a `SQLAlchemy expression `_. The returned + a plain text string, or a `SQLAlchemy expression `_. The returned iterator will yield each result sequentially. Any keyword arguments will be passed into the query to perform From 9e43b6697bbe114ba4a2252b4c23862a99448a25 Mon Sep 17 00:00:00 2001 From: Vladimir Ulupov Date: Mon, 6 Oct 2014 18:31:55 +0400 Subject: [PATCH 8/8] fix typo --- docs/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/quickstart.rst b/docs/quickstart.rst index aa8a00e..f5f0cc4 100644 --- a/docs/quickstart.rst +++ b/docs/quickstart.rst @@ -92,7 +92,7 @@ Nested transactions are supported too:: db = dataset.connect() with db as tx1: tx1['user'].insert(dict(name='John Doe', age=46, country='China')) - with db sa tx2: + with db as tx2: tx2['user'].insert(dict(name='Jane Doe', age=37, country='France', gender='female'))