[Python-modules-commits] [python-agate-sql] 01/04: New upstream version 0.5.2

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Fri May 5 17:47:21 UTC 2017


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository python-agate-sql.

commit ce7f6fab96b0bd14cfef9e3fb60d57011deaa667
Author: Ghislain Antony Vaillant <ghisvail at gmail.com>
Date:   Tue May 2 08:44:43 2017 +0100

    New upstream version 0.5.2
---
 AUTHORS.rst            |   1 +
 CHANGELOG.rst          |   9 +++++++--
 agatesql/table.py      |   6 ++++--
 docs/conf.py           |   6 +++---
 example.db             | Bin 2048 -> 2048 bytes
 setup.py               |   3 ++-
 tests/test_agatesql.py |  22 ++++++++++++++++++++++
 7 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/AUTHORS.rst b/AUTHORS.rst
index 9bcb640..919001b 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -6,3 +6,4 @@ The following individuals have contributed code to agate-sql:
 * `Chris Keller <https://github.com/chrislkeller>`_
 * `git-clueless <https://github.com/git-clueless>`_
 * `z2s8 <https://github.com/z2s8>`_
+* `Jake Zimmerman <https://github.com/jez>`_
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index c0a58e5..93a4a41 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -1,5 +1,10 @@
-0.5.1 -  February 27, 2017
---------------------------
+0.5.2 - April 28, 2017
+----------------------
+
+* Add ``create_if_not_exists`` flag to :meth:`.TableSQL.to_sql`.
+
+0.5.1 - February 27, 2017
+-------------------------
 
 * Add ``prefixes`` option to :func:`.to_sql` to add expressions following the INSERT keyword, like OR IGNORE or OR REPLACE.
 * Use ``TIMESTAMP`` instead of ``DATETIME`` for DateTime columns.
diff --git a/agatesql/table.py b/agatesql/table.py
index 93a468a..7301a3c 100644
--- a/agatesql/table.py
+++ b/agatesql/table.py
@@ -176,7 +176,7 @@ def make_sql_table(table, table_name, dialect=None, db_schema=None, constraints=
 
     return sql_table
 
-def to_sql(self, connection_or_string, table_name, overwrite=False, create=True, insert=True, prefixes=[], db_schema=None, constraints=True):
+def to_sql(self, connection_or_string, table_name, overwrite=False, create=True, create_if_not_exists=False, insert=True, prefixes=[], db_schema=None, constraints=True):
     """
     Write this table to the given SQL database.
 
@@ -190,6 +190,8 @@ def to_sql(self, connection_or_string, table_name, overwrite=False, create=True,
         Drop any existing table with the same name before creating.
     :param create:
         Create the table.
+    :param create_if_not_exists:
+        When creating the table, don't fail if the table already exists.
     :param insert:
         Insert table data.
     :param prefixes:
@@ -208,7 +210,7 @@ def to_sql(self, connection_or_string, table_name, overwrite=False, create=True,
         if overwrite:
             sql_table.drop(checkfirst=True)
 
-        sql_table.create()
+        sql_table.create(checkfirst=create_if_not_exists)
 
     if insert:
         insert = sql_table.insert()
diff --git a/docs/conf.py b/docs/conf.py
index c328d64..baaa2c5 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -45,16 +45,16 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'agate-sql'
-copyright = u'2015, Christopher Groskopf'
+copyright = u'2017, Christopher Groskopf'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '0.5.1'
+version = '0.5.2'
 # The full version, including alpha/beta/rc tags.
-release = '0.5.1 (alpha)'
+release = '0.5.2 (beta)'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
diff --git a/example.db b/example.db
index 163f76e..82ace40 100644
Binary files a/example.db and b/example.db differ
diff --git a/setup.py b/setup.py
index 047dedd..e10eb4f 100644
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ install_requires = [
 
 setup(
     name='agate-sql',
-    version='0.5.1',
+    version='0.5.2',
     description='agate-sql adds SQL read/write support to agate.',
     long_description=open('README.rst').read(),
     author='Christopher Groskopf',
@@ -28,6 +28,7 @@ setup(
         'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Topic :: Multimedia :: Graphics',
diff --git a/tests/test_agatesql.py b/tests/test_agatesql.py
index a270222..9aab2f9 100644
--- a/tests/test_agatesql.py
+++ b/tests/test_agatesql.py
@@ -54,6 +54,28 @@ class TestSQL(agate.AgateTestCase):
         self.assertEqual(len(table.rows), len(self.table.rows))
         self.assertSequenceEqual(table.rows[0], self.table.rows[0])
 
+    def test_create_if_not_exists(self):
+        column_names = ['id', 'name']
+        column_types = [agate.Number(), agate.Text()]
+        rows1 = (
+            (1, 'Jake'),
+            (2, 'Howard'),
+        )
+        rows2 = (
+            (3, 'Liz'),
+            (4, 'Tim'),
+        )
+
+        table1 = agate.Table(rows1, column_names, column_types)
+        table2 = agate.Table(rows2, column_names, column_types)
+
+        engine = create_engine(self.connection_string)
+        connection = engine.connect()
+
+        # Write two agate tables into the same SQL table
+        table1.to_sql(connection, 'create_if_not_exists_test', create=True, create_if_not_exists=True, insert=True)
+        table2.to_sql(connection, 'create_if_not_exists_test', create=True, create_if_not_exists=True, insert=True)
+
     def test_to_sql_create_statement(self):
         statement = self.table.to_sql_create_statement('test_table')
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-agate-sql.git



More information about the Python-modules-commits mailing list