def insert_chunk(self, name, chunk): headers = self.get_headers(name, del_id=True) values = list( map(lambda x: TableHelper.prepare_values(headers, x), chunk)) self.conn.execute(self._tables[name].insert(), values)
def test_add_table(self): table = TableHelper.make_table("addtable", self.cache.metadata, self.headers) self.cache.add_table("addtable", table) self.assertIsInstance(self.cache._tables['addtable'], Table)
def test_make_table(self): urlsql = "sqlite://" sql = SQL(urlsql) table = TableHelper.make_table("test", sql.metadata, self.headers) self.assertIsInstance(table, Table)
def insert_row(self, name, values): """ Recibe `name` str es el tipo de tabla. Y values que puede ser un vector. : """ headers = self.get_headers(name) # tiene que borrar el id headers.pop(0) keys_values = TableHelper.prepare_values(headers, values) #keys_values=self._tables[name].prepare_values(values) self.conn.execute(self._tables[name].insert(), **keys_values)
def create_table(self, name, headers): table = TableHelper.make_table(name, self.metadata, headers) table.create(self.engine, checkfirst=True) self.add_table(name, table)
def test_make_columns_coltype(self): c = TableHelper.make_columns("test", self.headers) self.assertIsInstance(c[0], Column)
def test_make_columns(self): c = TableHelper.make_columns("test", self.headers) self.assertEqual(len(c), len(self.headers) + 1)