Skip to content

Commit c751b4f

Browse files
committed
defer isave_as and isave_book_as roll-out
1 parent 3f2dc31 commit c751b4f

File tree

3 files changed

+22
-54
lines changed

3 files changed

+22
-54
lines changed

CHANGELOG.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
Change log
22
================================================================================
33

4+
0.1.1 - deferred
5+
--------------------------------------------------------------------------------
6+
7+
Added
8+
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9+
10+
#. To bring isave_as and isave_book_as to web clients
11+
412
0.1.0 - unreleased
513
--------------------------------------------------------------------------------
614

715
Added
816
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
917

10-
#. To bring iget_array, iget_records, isave_as and isave_book_as to web clients
18+
#. To bring iget_array, iget_records to web clients
1119
#. To facilitate the use of pyexcel-handsontable, pyexcel-pygal
1220

1321
0.0.11 - 04.03.2017

pyexcel_webio/__init__.py

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -165,34 +165,6 @@ def save_to_database(self, session=None, table=None,
165165
params['dest_auto_commit'] = auto_commit
166166
pe.save_as(**params)
167167

168-
def isave_to_database(self, session=None, table=None,
169-
initializer=None, mapdict=None,
170-
auto_commit=True,
171-
**keywords):
172-
"""
173-
Save data from a sheet to database
174-
175-
:param session: a SQLAlchemy session
176-
:param table: a database table
177-
:param initializer: a custom table initialization function if
178-
you have one
179-
:param mapdict: the explicit table column names if your excel
180-
data do not have the exact column names
181-
:param keywords: additional keywords to
182-
:meth:`pyexcel.Sheet.save_to_database`
183-
"""
184-
params = self.get_params(**keywords)
185-
if 'name_columns_by_row' not in params:
186-
params['name_columns_by_row'] = 0
187-
if 'name_rows_by_column' not in params:
188-
params['name_rows_by_column'] = -1
189-
params['dest_session'] = session
190-
params['dest_table'] = table
191-
params['dest_initializer'] = initializer
192-
params['dest_mapdict'] = mapdict
193-
params['dest_auto_commit'] = auto_commit
194-
pe.isave_as(**params)
195-
196168
def get_book(self, **keywords):
197169
"""Get a instance of :class:`Book` from the file
198170
@@ -236,31 +208,6 @@ def save_book_to_database(self, session=None, tables=None,
236208
params['dest_auto_commit'] = auto_commit
237209
pe.save_book_as(**params)
238210

239-
def isave_book_to_database(self, session=None, tables=None,
240-
initializers=None, mapdicts=None,
241-
auto_commit=True, **keywords):
242-
"""
243-
Save a big book into database
244-
245-
:param session: a SQLAlchemy session
246-
:param tables: a list of database tables
247-
:param initializers: a list of model
248-
initialization functions.
249-
:param mapdicts: a list of explicit table column names
250-
if your excel data sheets do not have
251-
the exact column names
252-
:param keywords: additional keywords to
253-
:meth:`pyexcel.Book.save_to_database`
254-
255-
"""
256-
params = self.get_params(**keywords)
257-
params['dest_session'] = session
258-
params['dest_tables'] = tables
259-
params['dest_initializers'] = initializers
260-
params['dest_mapdicts'] = mapdicts
261-
params['dest_auto_commit'] = auto_commit
262-
pe.isave_book_as(**params)
263-
264211

265212
class ExcelInputInMultiDict(ExcelInput):
266213
"""

tests/test_webio.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ def test_get_array(self):
9797
array = myinput.get_array(file_name=self.testfile)
9898
assert array == self.data
9999

100+
def test_iget_array(self):
101+
myinput = TestInput()
102+
array = myinput.iget_array(file_name=self.testfile)
103+
assert list(array) == self.data
104+
100105
def test_get_dict(self):
101106
myinput = TestInput()
102107
result = myinput.get_dict(file_name=self.testfile)
@@ -114,6 +119,14 @@ def test_get_records(self):
114119
{"X": 4, "Y": 5, "Z": 6}
115120
]
116121

122+
def test_iget_records(self):
123+
myinput = TestInput()
124+
result = myinput.get_records(file_name=self.testfile)
125+
assert list(result) == [
126+
{"X": 1, "Y": 2, "Z": 3},
127+
{"X": 4, "Y": 5, "Z": 6}
128+
]
129+
117130
def test_save_to_database(self):
118131
Base.metadata.drop_all(engine)
119132
Base.metadata.create_all(engine)

0 commit comments

Comments
 (0)