def test_one_table_using_mapdict_as_dict(self): mysession = Session() self.data = [ ["Birth Date", "Id", "Name", "Weight"], [datetime.date(2014, 11, 11), 0, "Adam", 11.25], [datetime.date(2014, 11, 12), 1, "Smith", 12.25], ] mapdict = { "Birth Date": "birth", "Id": "id", "Name": "name", "Weight": "weight", } importer = SQLTableImporter(mysession) adapter = SQLTableImportAdapter(Pyexcel) adapter.column_names = self.data[0] adapter.column_name_mapping_dict = mapdict writer = SQLTableWriter(importer, adapter) writer.write_array(self.data[1:]) writer.close() query_sets = mysession.query(Pyexcel).all() results = QuerysetsReader( query_sets, ["birth", "id", "name", "weight"] ).to_array() assert list(results) == self.results mysession.close()
def test_one_table_using_mapdict_as_dict(self): mysession = Session() self.data = [ ["Birth Date", "Id", "Name", "Weight"], [datetime.date(2014, 11, 11), 0, "Adam", 11.25], [datetime.date(2014, 11, 12), 1, "Smith", 12.25], ] mapdict = { "Birth Date": "birth", "Id": "id", "Name": "name", "Weight": "weight", } importer = SQLTableImporter(mysession) adapter = SQLTableImportAdapter(Pyexcel) adapter.column_names = self.data[0] adapter.column_name_mapping_dict = mapdict writer = SQLTableWriter(importer, adapter) writer.write_array(self.data[1:]) writer.close() query_sets = mysession.query(Pyexcel).all() results = QuerysetsReader( query_sets, ["birth", "id", "name", "weight"]).to_array() assert list(results) == self.results mysession.close()
def test_one_table_using_mapdict_as_array(self): mysession = Session() self.data = [["Birth Date", "Id", "Name", "Weight"], [datetime.date(2014, 11, 11), 0, 'Adam', 11.25], [datetime.date(2014, 11, 12), 1, 'Smith', 12.25]] mapdict = ['birth', 'id', 'name', 'weight'] importer = SQLTableImporter(mysession) adapter = SQLTableImportAdapter(Pyexcel) adapter.column_names = self.data[0] adapter.column_name_mapping_dict = mapdict writer = SQLTableWriter(importer, adapter) writer.write_array(self.data[1:]) writer.close() query_sets = mysession.query(Pyexcel).all() results = QuerysetsReader(query_sets, mapdict).to_array() assert list(results) == self.results mysession.close()