def test_copy_from_file(self): with self.subTest("with table as string"): q = VerticaQuery.from_file("/path/to/file").copy_("abc") self.assertEqual( "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", str(q), ) with self.subTest("with table"): q = VerticaQuery.from_file("/path/to/file").copy_(self.table_abc) self.assertEqual( "COPY \"abc\" FROM LOCAL '/path/to/file' PARSER fcsvparser(header=false)", str(q), )
def import_csv(self, table, file_path, connection=None): """ Imports a file into a database table. :param table: The name of a table to import data into. :param file_path: The path of the file to be imported. :param connection: (Optional) The connection to execute this query with. """ import_query = VerticaQuery.from_file(file_path).copy_(table) self.execute(str(import_query), connection=connection)