Naming file with sql query data

0

Hello, I need to name each file created by the script with a single column data from my database. Here is the code:

        for index, source in zip(list(range(0, len(self.sources))), self.sources):
        if self.jsonfile is not None and self.outdir is not None:
            path_file = '{}/{}_{}_{}'.format(self.outdir,
                                             datetime.now().strftime('%Y%m%d%H%M%S'),
                                             index,
                                             code[index]+'.json')

Where "code" is the data of my database column, and index is the number of files and will stay to look like this:

20170920145732_0_CODE1.json

20170920145732_1_CODE2.json

20170920145732_2_CODE3.json

The initial numbers are date and time and after the first underscore comes the index, and finally comes the data from the database column.

My sql query:

sql = 'SELECT code from data.est where name = code and id = 13'
    
asked by anonymous 20.09.2017 / 19:49

0 answers