Hello community,
here is the log from the commit of package python-agate-sql for
openSUSE:Factory checked in at 2019-04-18 13:58:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-agate-sql (Old)
and /work/SRC/openSUSE:Factory/.python-agate-sql.new.5536 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-agate-sql"
Thu Apr 18 13:58:34 2019 rev:2 rq:695447 version:0.5.4
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-agate-sql/python-agate-sql.changes
2018-05-29 16:47:58.973294189 +0200
+++
/work/SRC/openSUSE:Factory/.python-agate-sql.new.5536/python-agate-sql.changes
2019-04-18 13:58:36.727998963 +0200
@@ -1,0 +2,15 @@
+Wed Apr 17 11:44:43 UTC 2019 - [email protected]
+
+- version update to 0.5.4
+ * Add ``min_col_len`` and ``col_len_multiplier`` options to
+ :meth:`.Table.to_sql` to control the length of text columns.
+ * agate-sql is now tested against Python 3.7.
+ * Drop support for Python 3.3 (end-of-life was September 29, 2017).
+ * Add support for CrateDB.
+ * Set type to ``BIT`` for boolean (MS SQL).
+ * Eliminate SQLite warning about Decimal numbers.
+- added patches
+ we do not have crate dialect
+ + python-agate-sql-no-crate.patch
+
+-------------------------------------------------------------------
Old:
----
agate-sql-0.5.3.tar.gz
New:
----
0.5.4.tar.gz
python-agate-sql-no-crate.patch
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-agate-sql.spec ++++++
--- /var/tmp/diff_new_pack.KNYgFd/_old 2019-04-18 13:58:37.471999211 +0200
+++ /var/tmp/diff_new_pack.KNYgFd/_new 2019-04-18 13:58:37.471999211 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-agate-sql
#
-# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -12,29 +12,32 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
+#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
-%bcond_with test
Name: python-agate-sql
-Version: 0.5.3
+Version: 0.5.4
Release: 0
-License: MIT
Summary: SQL read/write support for agate
-Url: http://agate-sql.readthedocs.org/
+License: MIT
Group: Development/Languages/Python
-Source:
https://files.pythonhosted.org/packages/source/a/agate-sql/agate-sql-%{version}.tar.gz
+Url: http://agate-sql.readthedocs.org/
+Source:
https://github.com/wireservice/agate-sql/archive/%{version}.tar.gz
+# we do not have crate dialect
+Patch0: python-agate-sql-no-crate.patch
BuildRequires: %{python_module devel}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
-%if %{with test}
-BuildRequires: %{python_module agate >= 1.5.0}
+# SECTION test requirements
BuildRequires: %{python_module SQLAlchemy >= 1.0.8}
-%endif
-Requires: python-agate >= 1.5.0
+BuildRequires: %{python_module agate >= 1.5.0}
+BuildRequires: %{python_module nose}
+# /SECTION
Requires: python-SQLAlchemy >= 1.0.8
+Requires: python-agate >= 1.5.0
BuildArch: noarch
%python_subpackages
@@ -44,6 +47,7 @@
%prep
%setup -q -n agate-sql-%{version}
+%patch0 -p1
sed -i -e '/^#!\//, 1d' agatesql/*.py
%build
@@ -53,14 +57,12 @@
%python_install
%python_expand %fdupes %{buildroot}%{$python_sitelib}
-%if %{with test}
%check
-%python_exec setup.py test
-%endif
+%python_expand nosetests-%{$python_bin_suffix}
%files %{python_files}
%defattr(-,root,root,-)
-%doc AUTHORS.rst README.rst
+%doc AUTHORS.rst README.rst CHANGELOG.rst
%license COPYING
%{python_sitelib}/*
++++++ agate-sql-0.5.3.tar.gz -> 0.5.4.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/.gitignore
new/agate-sql-0.5.4/.gitignore
--- old/agate-sql-0.5.3/.gitignore 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/.gitignore 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,12 @@
+.DS_Store
+*.pyc
+*.swp
+*.swo
+.tox
+*.egg-info
+docs/_build
+dist
+.coverage
+build
+.proof
+.test.png
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/.travis.yml
new/agate-sql-0.5.4/.travis.yml
--- old/agate-sql-0.5.3/.travis.yml 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/.travis.yml 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,14 @@
+dist: xenial
+language: python
+python:
+ - "2.7"
+ - "3.4"
+ - "3.5"
+ - "3.6"
+ - "3.7"
+# command to install dependencies
+install:
+ - if [[ $TRAVIS_PYTHON_VERSION == 3* ]]; then pip install -r
requirements-py3.txt; else pip install -r requirements-py2.txt; fi
+# command to run tests
+script: nosetests tests
+sudo: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/AUTHORS.rst
new/agate-sql-0.5.4/AUTHORS.rst
--- old/agate-sql-0.5.3/AUTHORS.rst 2018-01-28 00:44:21.000000000 +0100
+++ new/agate-sql-0.5.4/AUTHORS.rst 2019-03-16 17:22:33.000000000 +0100
@@ -8,3 +8,4 @@
* `z2s8 <https://github.com/z2s8>`_
* `Jake Zimmerman <https://github.com/jez>`_
* `Shige Takeda <https://github.com/smtakeda>`_
+* `Roger Webb <https://github.com/RogerWebb>`_
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/CHANGELOG.rst
new/agate-sql-0.5.4/CHANGELOG.rst
--- old/agate-sql-0.5.3/CHANGELOG.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/CHANGELOG.rst 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,69 @@
+0.5.4 - March 16, 2019
+----------------------
+
+* Add ``min_col_len`` and ``col_len_multiplier`` options to
:meth:`.Table.to_sql` to control the length of text columns.
+* agate-sql is now tested against Python 3.7.
+* Drop support for Python 3.3 (end-of-life was September 29, 2017).
+
+Dialect-specific:
+
+* Add support for CrateDB.
+* Set type to ``BIT`` for boolean (MS SQL).
+* Eliminate SQLite warning about Decimal numbers.
+
+0.5.3 - January 28, 2018
+------------------------
+
+* Add ``chunk_size`` option to :meth:`.Table.to_sql` to write rows in batches.
+* Add ``unique_constraint`` option to :meth:`.Table.to_sql` to include in a
UNIQUE constraint.
+
+Dialect-specific:
+
+* Specify precision and scale for ``DECIMAL`` (MS SQL, MySQL, Oracle).
+* Set length of ``VARCHAR`` to ``1`` even if maximum length is ``0`` (MySQL).
+* Set type to ``TEXT`` if maximum length is greater than 21,844 (MySQL).
+
+0.5.2 - April 28, 2017
+----------------------
+
+* Add ``create_if_not_exists`` flag to :meth:`.Table.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.
+
+0.5.0 - December 23, 2016
+-------------------------
+
+* ``VARCHAR`` columns are now generated with proper length constraints (unless
explicilty disabled).
+* Tables can now be created from query results using :func:`.from_sql_query`.
+* Add support for running queries directly on tables with :func:`.sql_query`.
+* When creating tables, ``NOT NULL`` constraints will be created by default.
+* SQL create statements can now be generated without being executed with
:func:`.to_sql_create_statement`
+
+0.4.0 - December 19, 2016
+-------------------------
+
+* Modified ``example.py`` so it no longer depends on Postgres.
+* It is no longer necessary to run :code:`agatesql.patch()` after importing
agatesql.
+* Upgrade required agate to ``1.5.0``.
+
+0.3.0 - November 5, 2015
+------------------------
+
+* Add ``overwrite`` flag to :meth:`.Table.to_sql`.
+* Removed Python 2.6 support.
+* Updated agate dependency to version 1.1.0.
+* Additional SQL types are now supported. (#4, #10)
+
+0.2.0 - October 22, 2015
+------------------------
+
+* Add explicit patch function.
+
+0.1.0 - September 22, 2015
+--------------------------
+
+* Initial version.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/PKG-INFO new/agate-sql-0.5.4/PKG-INFO
--- old/agate-sql-0.5.3/PKG-INFO 2018-01-28 06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/PKG-INFO 1970-01-01 01:00:00.000000000 +0100
@@ -1,52 +0,0 @@
-Metadata-Version: 1.1
-Name: agate-sql
-Version: 0.5.3
-Summary: agate-sql adds SQL read/write support to agate.
-Home-page: http://agate-sql.readthedocs.org/
-Author: Christopher Groskopf
-Author-email: [email protected]
-License: MIT
-Description: .. image:: https://travis-ci.org/wireservice/agate-sql.png
- :target: https://travis-ci.org/wireservice/agate-sql
- :alt: Build status
-
- .. image:: https://img.shields.io/pypi/v/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: Version
-
- .. image:: https://img.shields.io/pypi/l/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: License
-
- .. image:: https://img.shields.io/pypi/pyversions/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: Support Python versions
-
- agate-sql adds SQL read/write support to `agate
<https://github.com/wireservice/agate>`_.
-
- Important links:
-
- * agate http://agate.rtfd.org
- * Documentation: http://agate-sql.rtfd.org
- * Repository: https://github.com/wireservice/agate-sql
- * Issues: https://github.com/wireservice/agate-sql/issues
-
-Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
-Classifier: Intended Audience :: Developers
-Classifier: Intended Audience :: Science/Research
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Natural Language :: English
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
-Classifier: Programming Language :: Python :: Implementation :: CPython
-Classifier: Programming Language :: Python :: Implementation :: PyPy
-Classifier: Topic :: Multimedia :: Graphics
-Classifier: Topic :: Scientific/Engineering :: Information Analysis
-Classifier: Topic :: Scientific/Engineering :: Visualization
-Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/agate_sql.egg-info/PKG-INFO
new/agate-sql-0.5.4/agate_sql.egg-info/PKG-INFO
--- old/agate-sql-0.5.3/agate_sql.egg-info/PKG-INFO 2018-01-28
06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/agate_sql.egg-info/PKG-INFO 1970-01-01
01:00:00.000000000 +0100
@@ -1,52 +0,0 @@
-Metadata-Version: 1.1
-Name: agate-sql
-Version: 0.5.3
-Summary: agate-sql adds SQL read/write support to agate.
-Home-page: http://agate-sql.readthedocs.org/
-Author: Christopher Groskopf
-Author-email: [email protected]
-License: MIT
-Description: .. image:: https://travis-ci.org/wireservice/agate-sql.png
- :target: https://travis-ci.org/wireservice/agate-sql
- :alt: Build status
-
- .. image:: https://img.shields.io/pypi/v/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: Version
-
- .. image:: https://img.shields.io/pypi/l/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: License
-
- .. image:: https://img.shields.io/pypi/pyversions/agate-sql.svg
- :target: https://pypi.python.org/pypi/agate-sql
- :alt: Support Python versions
-
- agate-sql adds SQL read/write support to `agate
<https://github.com/wireservice/agate>`_.
-
- Important links:
-
- * agate http://agate.rtfd.org
- * Documentation: http://agate-sql.rtfd.org
- * Repository: https://github.com/wireservice/agate-sql
- * Issues: https://github.com/wireservice/agate-sql/issues
-
-Platform: UNKNOWN
-Classifier: Development Status :: 4 - Beta
-Classifier: Intended Audience :: Developers
-Classifier: Intended Audience :: Science/Research
-Classifier: License :: OSI Approved :: MIT License
-Classifier: Natural Language :: English
-Classifier: Operating System :: OS Independent
-Classifier: Programming Language :: Python
-Classifier: Programming Language :: Python :: 2.7
-Classifier: Programming Language :: Python :: 3.3
-Classifier: Programming Language :: Python :: 3.4
-Classifier: Programming Language :: Python :: 3.5
-Classifier: Programming Language :: Python :: 3.6
-Classifier: Programming Language :: Python :: Implementation :: CPython
-Classifier: Programming Language :: Python :: Implementation :: PyPy
-Classifier: Topic :: Multimedia :: Graphics
-Classifier: Topic :: Scientific/Engineering :: Information Analysis
-Classifier: Topic :: Scientific/Engineering :: Visualization
-Classifier: Topic :: Software Development :: Libraries :: Python Modules
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/agate_sql.egg-info/SOURCES.txt
new/agate-sql-0.5.4/agate_sql.egg-info/SOURCES.txt
--- old/agate-sql-0.5.3/agate_sql.egg-info/SOURCES.txt 2018-01-28
06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/agate_sql.egg-info/SOURCES.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1,13 +0,0 @@
-AUTHORS.rst
-COPYING
-MANIFEST.in
-README.rst
-setup.cfg
-setup.py
-agate_sql.egg-info/PKG-INFO
-agate_sql.egg-info/SOURCES.txt
-agate_sql.egg-info/dependency_links.txt
-agate_sql.egg-info/requires.txt
-agate_sql.egg-info/top_level.txt
-agatesql/__init__.py
-agatesql/table.py
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/agate-sql-0.5.3/agate_sql.egg-info/dependency_links.txt
new/agate-sql-0.5.4/agate_sql.egg-info/dependency_links.txt
--- old/agate-sql-0.5.3/agate_sql.egg-info/dependency_links.txt 2018-01-28
06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/agate_sql.egg-info/dependency_links.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1 +0,0 @@
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/agate_sql.egg-info/requires.txt
new/agate-sql-0.5.4/agate_sql.egg-info/requires.txt
--- old/agate-sql-0.5.3/agate_sql.egg-info/requires.txt 2018-01-28
06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/agate_sql.egg-info/requires.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-agate>=1.5.0
-sqlalchemy>=1.0.8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/agate_sql.egg-info/top_level.txt
new/agate-sql-0.5.4/agate_sql.egg-info/top_level.txt
--- old/agate-sql-0.5.3/agate_sql.egg-info/top_level.txt 2018-01-28
06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/agate_sql.egg-info/top_level.txt 1970-01-01
01:00:00.000000000 +0100
@@ -1 +0,0 @@
-agatesql
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/agatesql/table.py
new/agate-sql-0.5.4/agatesql/table.py
--- old/agate-sql-0.5.3/agatesql/table.py 2018-01-28 06:31:48.000000000
+0100
+++ new/agate-sql-0.5.4/agatesql/table.py 2019-03-16 17:22:33.000000000
+0100
@@ -11,24 +11,34 @@
import agate
from sqlalchemy import Column, MetaData, Table, UniqueConstraint,
create_engine, dialects
from sqlalchemy.engine import Connection
-from sqlalchemy.types import BOOLEAN, DECIMAL, DATE, TEXT, TIMESTAMP, VARCHAR,
Interval
+from sqlalchemy.types import BOOLEAN, DATE, DECIMAL, FLOAT, TEXT, TIMESTAMP,
VARCHAR, Interval
+from sqlalchemy.dialects.mssql import BIT
from sqlalchemy.dialects.oracle import INTERVAL as ORACLE_INTERVAL
from sqlalchemy.dialects.postgresql import INTERVAL as POSTGRES_INTERVAL
from sqlalchemy.schema import CreateTable
from sqlalchemy.sql import select
SQL_TYPE_MAP = {
- agate.Boolean: BOOLEAN,
- agate.Number: DECIMAL,
+ agate.Boolean: None, # See below
+ agate.Number: None, # See below
agate.Date: DATE,
agate.DateTime: TIMESTAMP,
agate.TimeDelta: None, # See below
- agate.Text: VARCHAR
+ agate.Text: VARCHAR,
+}
+
+BOOLEAN_MAP = {
+ 'mssql': BIT,
+}
+
+NUMBER_MAP = {
+ 'crate': FLOAT,
+ 'sqlite': FLOAT,
}
INTERVAL_MAP = {
'postgresql': POSTGRES_INTERVAL,
- 'oracle': ORACLE_INTERVAL
+ 'oracle': ORACLE_INTERVAL,
}
@@ -161,17 +171,16 @@
def make_sql_table(table, table_name, dialect=None, db_schema=None,
constraints=True, unique_constraint=[],
- connection=None):
+ connection=None, min_col_len=1, col_len_multiplier=1):
"""
Generates a SQL alchemy table from an agate table.
"""
metadata = MetaData(connection)
sql_table = Table(table_name, metadata, schema=db_schema)
- if dialect in INTERVAL_MAP.keys():
- SQL_TYPE_MAP[agate.TimeDelta] = INTERVAL_MAP[dialect]
- else:
- SQL_TYPE_MAP[agate.TimeDelta] = Interval
+ SQL_TYPE_MAP[agate.Boolean] = BOOLEAN_MAP.get(dialect, BOOLEAN)
+ SQL_TYPE_MAP[agate.Number] = NUMBER_MAP.get(dialect, DECIMAL)
+ SQL_TYPE_MAP[agate.TimeDelta] = INTERVAL_MAP.get(dialect, Interval)
for column_name, column in table.columns.items():
sql_column_type = None
@@ -180,13 +189,13 @@
if constraints:
if isinstance(column.data_type, agate.Text) and dialect == 'mysql':
- length = table.aggregate(agate.MaxLength(column_name))
+ length = table.aggregate(agate.MaxLength(column_name)) *
decimal.Decimal(col_len_multiplier)
if length > 21844:
# @see
https://dev.mysql.com/doc/refman/5.7/en/string-type-overview.html
sql_column_type = TEXT
else:
# If length is zero, SQLAlchemy may raise "VARCHAR
requires a length on dialect mysql".
- sql_type_kwargs['length'] = length or 1
+ sql_type_kwargs['length'] = length if length >=
min_col_len else min_col_len
# PostgreSQL and SQLite don't have scale default 0.
# @see
https://www.postgresql.org/docs/9.2/static/datatype-numeric.html
@@ -216,7 +225,8 @@
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, unique_constraint=[],
chunk_size=None):
+ db_schema=None, constraints=True, unique_constraint=[],
chunk_size=None,
+ min_col_len=1, col_len_multiplier=1):
"""
Write this table to the given SQL database.
@@ -244,12 +254,17 @@
The names of the columns to include in a UNIQUE constraint.
:param chunk_size
Write rows in batches of this size. If not set, rows will be written
at once.
+ :param col_min_len
+ The minimum length of text columns.
+ :param col_len_multiplier
+ Multiply the maximum column length by this multiplier to accomodate
larger values in later runs.
"""
engine, connection = get_engine_and_connection(connection_or_string)
dialect = connection.engine.dialect.name
sql_table = make_sql_table(self, table_name, dialect=dialect,
db_schema=db_schema, constraints=constraints,
- unique_constraint=unique_constraint,
connection=connection)
+ unique_constraint=unique_constraint,
connection=connection,
+ min_col_len=min_col_len,
col_len_multiplier=col_len_multiplier)
if create:
if overwrite:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/docs/Makefile
new/agate-sql-0.5.4/docs/Makefile
--- old/agate-sql-0.5.3/docs/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/docs/Makefile 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,130 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp
epub latex latexpdf text man changes linkcheck doctest
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or
PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " changes to make an overview of all changed/added/deprecated
items"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation
(if enabled)"
+
+clean:
+ -rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the"
\
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/agatesql.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/agatesql.qhc"
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/agatesql"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/agatesql"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ make -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/docs/conf.py
new/agate-sql-0.5.4/docs/conf.py
--- old/agate-sql-0.5.3/docs/conf.py 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/docs/conf.py 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,227 @@
+# -*- coding: utf-8 -*-
+#
+# flake8: noqa
+#
+# This file is execfile()d with the current directory set to its containing
dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import os
+import sys
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('..'))
+
+# -- General configuration
-----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx']
+autodoc_member_order = 'bysource'
+
+intersphinx_mapping = {
+ 'python': ('http://docs.python.org/3.5/', None),
+ 'agate': ('http://agate.readthedocs.org/en/latest/', None)
+}
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'agate-sql'
+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.4'
+# The full version, including alpha/beta/rc tags.
+release = '0.5.4 (beta)'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output
---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+
+on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
+
+if not on_rtd: # only import and set the theme if we're building docs locally
+ import sphinx_rtd_theme
+ html_theme = 'sphinx_rtd_theme'
+ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'agatesqldoc'
+
+
+# -- Options for LaTeX output
--------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass
[howto/manual]).
+latex_documents = [
+ ('index', 'agate-sql.tex', u'agate-sql Documentation',
+ u'Christopher Groskopf', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output
--------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/docs/index.rst
new/agate-sql-0.5.4/docs/index.rst
--- old/agate-sql-0.5.3/docs/index.rst 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/docs/index.rst 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,82 @@
+===================
+agate-sql |release|
+===================
+
+.. include:: ../README.rst
+
+Install
+=======
+
+To install:
+
+.. code-block:: bash
+
+ pip install agate-sql
+
+For details on development or supported platforms see the `agate documentation
<http://agate.readthedocs.org>`_.
+
+.. warning::
+
+ You'll need to have the correct `sqlalchemy drivers
<http://docs.sqlalchemy.org/en/rel_1_0/dialects/index.html>`_ installed for
whatever database you plan to access. For instance, in order to read/write
tables in a Postgres database, you'll also need to ``pip install psycopg2``.
+
+Usage
+=====
+
+agate-sql uses a monkey patching pattern to add SQL support to all
:class:`agate.Table <agate.table.Table>` instances.
+
+.. code-block:: python
+
+ import agate
+ import agatesql
+
+Importing :mod:`.agatesql` attaches new methods to :class:`agate.Table
<agate.table.Table>`. For example, to import a table named :code:`doctors` from
a local postgresql database named :code:`hospitals` you will use
:meth:`.from_sql`:
+
+.. code-block:: python
+
+ new_table = agate.Table.from_sql('postgresql:///hospitals', 'doctors')
+
+To save this table back to the database:
+
+.. code-block:: python
+
+ new_table.to_sql('postgresql:///hospitals', 'doctors')
+
+The first argument to either function can be any valid `sqlalchemy connection
string <http://docs.sqlalchemy.org/en/rel_1_0/core/engines.html>`_. The second
argument must be a database name. (Arbitrary SQL queries are not supported.)
+
+That's all there is to it.
+
+===
+API
+===
+
+.. autofunction:: agatesql.table.from_sql
+
+.. autofunction:: agatesql.table.from_sql_query
+
+.. autofunction:: agatesql.table.to_sql
+
+.. autofunction:: agatesql.table.to_sql_create_statement
+
+.. autofunction:: agatesql.table.sql_query
+
+Authors
+=======
+
+.. include:: ../AUTHORS.rst
+
+Changelog
+=========
+
+.. include:: ../CHANGELOG.rst
+
+License
+=======
+
+.. include:: ../COPYING
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
Binary files old/agate-sql-0.5.3/example.db and new/agate-sql-0.5.4/example.db
differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/example.py
new/agate-sql-0.5.4/example.py
--- old/agate-sql-0.5.3/example.py 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/example.py 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+
+import agate
+import agatesql
+
+table = agate.Table.from_sql('sqlite:///example.db', 'test')
+
+print(table.column_names)
+print(table.column_types)
+print(len(table.columns))
+print(len(table.rows))
+
+table.to_sql('sqlite:///example.db', 'test', overwrite=True)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/requirements-py2.txt
new/agate-sql-0.5.4/requirements-py2.txt
--- old/agate-sql-0.5.3/requirements-py2.txt 1970-01-01 01:00:00.000000000
+0100
+++ new/agate-sql-0.5.4/requirements-py2.txt 2019-03-16 17:22:33.000000000
+0100
@@ -0,0 +1,3 @@
+-r requirements-py3.txt
+unittest2==0.5.1
+ordereddict>=1.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/requirements-py3.txt
new/agate-sql-0.5.4/requirements-py3.txt
--- old/agate-sql-0.5.3/requirements-py3.txt 1970-01-01 01:00:00.000000000
+0100
+++ new/agate-sql-0.5.4/requirements-py3.txt 2019-03-16 17:22:33.000000000
+0100
@@ -0,0 +1,8 @@
+crate
+nose>=1.1.2
+tox>=1.3
+Sphinx>=1.2.2
+sphinx_rtd_theme>=0.1.6
+wheel>=0.24.0
+agate>=1.5.0
+sqlalchemy>=1.0.8
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/setup.cfg
new/agate-sql-0.5.4/setup.cfg
--- old/agate-sql-0.5.3/setup.cfg 2018-01-28 06:39:58.000000000 +0100
+++ new/agate-sql-0.5.4/setup.cfg 2019-03-16 17:22:33.000000000 +0100
@@ -1,7 +1,2 @@
[bdist_wheel]
universal = 1
-
-[egg_info]
-tag_build =
-tag_date = 0
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/setup.py new/agate-sql-0.5.4/setup.py
--- old/agate-sql-0.5.3/setup.py 2017-08-04 16:07:27.000000000 +0200
+++ new/agate-sql-0.5.4/setup.py 2019-03-16 17:22:33.000000000 +0100
@@ -9,7 +9,7 @@
setup(
name='agate-sql',
- version='0.5.3',
+ version='0.5.4',
description='agate-sql adds SQL read/write support to agate.',
long_description=open('README.rst').read(),
author='Christopher Groskopf',
@@ -25,10 +25,10 @@
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
- 'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
+ 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Multimedia :: Graphics',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/tests/test_agatesql.py
new/agate-sql-0.5.4/tests/test_agatesql.py
--- old/agate-sql-0.5.3/tests/test_agatesql.py 1970-01-01 01:00:00.000000000
+0100
+++ new/agate-sql-0.5.4/tests/test_agatesql.py 2019-03-16 17:22:33.000000000
+0100
@@ -0,0 +1,259 @@
+#!/usr/bin/env python
+# -*- coding: utf8 -*-
+
+from decimal import Decimal
+
+import agate
+import agatesql # noqa
+from sqlalchemy import create_engine
+from sqlalchemy.exc import IntegrityError
+
+class TestSQL(agate.AgateTestCase):
+ def setUp(self):
+ self.rows = (
+ (1.123, 'a', True, '11/4/2015', '11/4/2015 12:22 PM'),
+ (2, u'👍', False, '11/5/2015', '11/4/2015 12:45 PM'),
+ (2, u'c', False, '11/5/2015', '11/4/2015 12:45 PM'),
+ (None, 'b', None, None, None),
+ )
+
+ self.column_names = [
+ 'number', 'text', 'boolean', 'date', 'datetime',
+ ]
+
+ self.column_types = [
+ agate.Number(), agate.Text(), agate.Boolean(),
+ agate.Date(), agate.DateTime(),
+ ]
+
+ self.table = agate.Table(self.rows, self.column_names,
self.column_types)
+ self.connection_string = 'sqlite:///:memory:'
+
+ def test_back_and_forth(self):
+ engine = create_engine(self.connection_string)
+ connection = engine.connect()
+
+ self.table.to_sql(connection, 'test')
+
+ table = agate.Table.from_sql(connection, 'test')
+
+ self.assertSequenceEqual(table.column_names, self.column_names)
+ self.assertIsInstance(table.column_types[0], agate.Number)
+ self.assertIsInstance(table.column_types[1], agate.Text)
+ self.assertIsInstance(table.column_types[2], agate.Boolean)
+ self.assertIsInstance(table.column_types[3], agate.Date)
+ self.assertIsInstance(table.column_types[4], agate.DateTime)
+
+ 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)
+
+ table = agate.Table.from_sql(connection, 'create_if_not_exists_test')
+ self.assertSequenceEqual(table.column_names, column_names)
+ self.assertIsInstance(table.column_types[0], agate.Number)
+ self.assertIsInstance(table.column_types[1], agate.Text)
+ self.assertEqual(len(table.rows), len(table1.rows) + len(table1.rows))
+ self.assertSequenceEqual(table.rows[0], table1.rows[0])
+
+ def test_unique_constraint(self):
+ engine = create_engine(self.connection_string)
+ connection = engine.connect()
+
+ with self.assertRaises(IntegrityError):
+ self.table.to_sql(connection, 'unique_constraint_test',
unique_constraint=['number'])
+
+ def test_prefixes(self):
+ engine = create_engine(self.connection_string)
+ connection = engine.connect()
+
+ self.table.to_sql(connection, 'prefixes_test', prefixes=['OR REPLACE'],
+ unique_constraint=['number'])
+
+ table = agate.Table.from_sql(connection, 'prefixes_test')
+
+ self.assertSequenceEqual(table.column_names, self.column_names)
+ self.assertIsInstance(table.column_types[0], agate.Number)
+ self.assertIsInstance(table.column_types[1], agate.Text)
+ self.assertIsInstance(table.column_types[2], agate.Boolean)
+ self.assertIsInstance(table.column_types[3], agate.Date)
+ self.assertIsInstance(table.column_types[4], agate.DateTime)
+
+ self.assertEqual(len(table.rows), len(self.table.rows) - 1)
+ self.assertSequenceEqual(table.rows[1], self.table.rows[2])
+
+ def test_to_sql_create_statement(self):
+ statement = self.table.to_sql_create_statement('test_table')
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_table (
+ number DECIMAL,
+ text VARCHAR NOT NULL,
+ boolean BOOLEAN,
+ date DATE,
+ datetime TIMESTAMP
+);''') # noqa
+
+ def test_to_sql_create_statement_no_constraints(self):
+ statement = self.table.to_sql_create_statement('test_table',
constraints=False)
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_table (
+ number DECIMAL,
+ text VARCHAR,
+ boolean BOOLEAN,
+ date DATE,
+ datetime TIMESTAMP
+);''') # noqa
+
+ def test_to_sql_create_statement_unique_constraint(self):
+ statement = self.table.to_sql_create_statement('test_table',
unique_constraint=['number', 'text'])
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_table (
+ number DECIMAL,
+ text VARCHAR NOT NULL,
+ boolean BOOLEAN,
+ date DATE,
+ datetime TIMESTAMP,
+ UNIQUE (number, text)
+);''') # noqa
+
+ def test_to_sql_create_statement_with_schema(self):
+ statement = self.table.to_sql_create_statement('test_table',
db_schema='test_schema', dialect='mysql')
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_schema.test_table (
+ number DECIMAL(38, 3),
+ text VARCHAR(1) NOT NULL,
+ boolean BOOL,
+ date DATE,
+ datetime TIMESTAMP NULL,
+ CHECK (boolean IN (0, 1))
+);''') # noqa
+
+ def test_to_sql_create_statement_with_dialects(self):
+ for dialect in ['crate', 'mssql', 'mysql', 'postgresql', 'sqlite']:
+ self.table.to_sql_create_statement('test_table', dialect=dialect)
+
+ def test_to_sql_create_statement_zero_width(self):
+ rows = ((1, ''), (2, ''))
+ column_names = ['id', 'name']
+ column_types = [agate.Number(), agate.Text()]
+ table = agate.Table(rows, column_names, column_types)
+
+ statement = table.to_sql_create_statement('test_table',
db_schema='test_schema', dialect='mysql')
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_schema.test_table (
+ id DECIMAL(38, 0) NOT NULL,
+ name VARCHAR(1)
+);''') # noqa
+
+ def test_to_sql_create_statement_wide_width(self):
+ rows = ((1, 'x' * 21845), (2, ''))
+ column_names = ['id', 'name']
+ column_types = [agate.Number(), agate.Text()]
+ table = agate.Table(rows, column_names, column_types)
+
+ statement = table.to_sql_create_statement('test_table',
db_schema='test_schema', dialect='mysql')
+
+ self.assertEqual(statement.replace('\t', ' '), '''CREATE TABLE
test_schema.test_table (
+ id DECIMAL(38, 0) NOT NULL,
+ name TEXT
+);''') # noqa
+
+ def test_make_sql_table_col_len_multiplier(self):
+ rows = ((1, 'x' * 10), (2, ''))
+ column_names = ['id', 'name']
+ column_types = [agate.Number(), agate.Text()]
+ table = agate.Table(rows, column_names, column_types)
+
+ sql_table = agatesql.table.make_sql_table(table, 'test_table',
dialect='mysql', db_schema='test_schema',
+ constraints=True,
col_len_multiplier=1.5)
+
+
+ self.assertEquals(sql_table.columns.get('name').type.length, 15)
+
+ def test_make_sql_table_min_col_len(self):
+ rows = ((1, 'x' * 10), (2, ''))
+ column_names = ['id', 'name']
+ column_types = [agate.Number(), agate.Text()]
+ table = agate.Table(rows, column_names, column_types)
+
+ sql_table = agatesql.table.make_sql_table(table, 'test_table',
dialect='mysql', db_schema='test_schema',
+ constraints=True,
min_col_len=20)
+
+
+ self.assertEquals(sql_table.columns.get('name').type.length, 20)
+
+ def test_sql_query_simple(self):
+ results = self.table.sql_query('select * from agate')
+
+ self.assertColumnNames(results, self.table.column_names)
+ self.assertRows(results, self.table.rows)
+
+ def test_sql_query_limit(self):
+ results = self.table.sql_query('select * from agate limit 2')
+
+ self.assertColumnNames(results, self.table.column_names)
+ self.assertRows(results, self.table.rows[:2])
+
+ def test_sql_query_select(self):
+ results = self.table.sql_query('select number, boolean from agate')
+
+ self.assertColumnNames(results, ['number', 'boolean'])
+ self.assertColumnTypes(results, [agate.Number, agate.Boolean])
+ self.assertRows(results, [
+ [Decimal('1.123'), True],
+ [2, False],
+ [2, False],
+ [None, None],
+ ])
+
+ def test_sql_query_aggregate(self):
+ results = self.table.sql_query('select sum(number) as total from
agate')
+
+ self.assertColumnNames(results, ['total'])
+ self.assertColumnTypes(results, [agate.Number])
+ self.assertRows(results, [[Decimal('5.123')]])
+
+ def test_chunk_size(self):
+ column_names = ['number']
+ column_types = [agate.Number()]
+
+ rows = []
+ expected = 0
+ for n in range(9999):
+ rows.append((n,))
+ expected += n
+
+ engine = create_engine(self.connection_string)
+ connection = engine.connect()
+
+ try:
+ table = agate.Table(rows, column_names, column_types)
+ table.to_sql(connection, 'test_chunk_size', overwrite=True,
chunk_size=100)
+
+ table = agate.Table.from_sql(connection, 'test_chunk_size')
+ actual = sum(r[0] for r in table.rows)
+ self.assertEqual(len(table.rows), len(rows))
+ self.assertEqual(expected, actual)
+ finally:
+ connection.close()
+ engine.dispose()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/agate-sql-0.5.3/tox.ini new/agate-sql-0.5.4/tox.ini
--- old/agate-sql-0.5.3/tox.ini 1970-01-01 01:00:00.000000000 +0100
+++ new/agate-sql-0.5.4/tox.ini 2019-03-16 17:22:33.000000000 +0100
@@ -0,0 +1,32 @@
+[tox]
+envlist = py27,py34,py35,py36,py37,pypy
+
+[testenv]
+deps=
+ nose>=1.1.2
+ six>=1.6.1
+commands=nosetests
+
+[testenv:py27]
+deps=
+ {[testenv]deps}
+
+[testenv:py34]
+deps=
+ {[testenv]deps}
+
+[testenv:py35]
+deps=
+ {[testenv:py33]deps}
+
+[testenv:py36]
+deps=
+ {[testenv:py33]deps}
+
+[testenv:py37]
+deps=
+ {[testenv:py33]deps}
+
+[testenv:pypy]
+deps=
+ {[testenv:py33]deps}
++++++ python-agate-sql-no-crate.patch ++++++
Index: agate-sql-0.5.4/tests/test_agatesql.py
===================================================================
--- agate-sql-0.5.4.orig/tests/test_agatesql.py 2019-03-16 17:22:33.000000000
+0100
+++ agate-sql-0.5.4/tests/test_agatesql.py 2019-04-17 13:38:17.158819021
+0200
@@ -149,7 +149,7 @@ class TestSQL(agate.AgateTestCase):
);''') # noqa
def test_to_sql_create_statement_with_dialects(self):
- for dialect in ['crate', 'mssql', 'mysql', 'postgresql', 'sqlite']:
+ for dialect in ['mssql', 'mysql', 'postgresql', 'sqlite']:
self.table.to_sql_create_statement('test_table', dialect=dialect)
def test_to_sql_create_statement_zero_width(self):