Team Ai
Apppublic

dorivanfernandes/convert_data_to_insert_sql

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
data_to_sql.py25 linesDownload Raw Back to tools
1from smolagents import Tool2from typing import Any, Optional3 4class SimpleTool(Tool):5    name = "data_to_sql"6    description = "Create insert SQL script to data. The first line must be the name of the fields"7    inputs = {"data":{"type":"object","description":"list of string with the value of the fields"}}8    output_type = "object"9 10    def forward(self, data: list) -> list:11        """12        Create insert SQL script to data. The first line must be the name of the fields13        Args:14            data: list of string with the value of the fields15        """16        header = data[0]17        newData = []18        for line in data:19          if(line == header): 20            continue21 22          # newData.append(f'insert into table_name ({header}) values ({line})')23          newData.append('insert into table_name ({}) values ({})'.format(header, line))24 25        return newData