# Path: taxtastic/utils.py
# def random_name(length):
#     return ''.join([random.choice(string.ascii_letters) for n in range(length)])


import itertools
import logging
import os
import re
import zipfile
import io
import sqlalchemy
from six.moves.urllib import request
from operator import itemgetter
from sqlalchemy import (Column, Integer, String, Boolean,
                        ForeignKey, Index, MetaData, PrimaryKeyConstraint)
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from taxtastic.utils import random_name

        log.info('creating an index on the temporary table')
        cmd = 'CREATE INDEX ix_{tempname}_tax_id on "{temptab}"(tax_id)'.format(
            tempname=tempname, **tablenames)
        log.info(cmd)
        cur.execute(cmd)

        log.info('updating names.is_classified')

        cmd = """
        UPDATE {names} SET
        is_classified = {placeholder}
        WHERE is_primary
        AND tax_id IN (SELECT tax_id FROM "{temptab}")
        """.format(placeholder=self.placeholder, **tablenames)

        log.info(cmd)
        cur.execute(cmd, (True,))
        conn.commit()

    def set_nodes_is_valid(self):
        conn = self.engine.raw_connection()
        cur = conn.cursor()

        cmd = """
        WITH RECURSIVE descendants AS (
         SELECT tax_id, parent_id, rank
         FROM {nodes}
         WHERE rank = 'species'
         AND tax_id not in (SELECT tax_id FROM {names} WHERE is_classified)

# Path: taxtastic/utils.py
# def random_name(length):
#     return ''.join([random.choice(string.ascii_letters) for n in range(length)])


# Path: taxtastic/ncbi.py
import itertools
import logging
import os
import re
import zipfile
import io
import sqlalchemy
from six.moves.urllib import request
from operator import itemgetter
from sqlalchemy import (Column, Integer, String, Boolean,
                        ForeignKey, Index, MetaData, PrimaryKeyConstraint)
from sqlalchemy.orm import relationship
from sqlalchemy.ext.declarative import declarative_base
from taxtastic.utils import random_name


        log.info('creating an index on the temporary table')
        cmd = 'CREATE INDEX ix_{tempname}_tax_id on "{temptab}"(tax_id)'.format(
            tempname=tempname, **tablenames)
        log.info(cmd)
        cur.execute(cmd)

        log.info('updating names.is_classified')

        cmd = """
        UPDATE {names} SET
        is_classified = {placeholder}
        WHERE is_primary
        AND tax_id IN (SELECT tax_id FROM "{temptab}")
        """.format(placeholder=self.placeholder, **tablenames)

        log.info(cmd)
        cur.execute(cmd, (True,))
        conn.commit()

    def set_nodes_is_valid(self):
        conn = self.engine.raw_connection()
        cur = conn.cursor()

        cmd = """
        WITH RECURSIVE descendants AS (
         SELECT tax_id, parent_id, rank
         FROM {nodes}
         WHERE rank = 'species'
         AND tax_id not in (SELECT tax_id FROM {names} WHERE is_classified)

         UNION