python teradata drop/create table

import db 
import sys 


def db_drop_create(table_name, db_connection=None): 
    if not db_connection:
        db_connection = db.get_logged_BteqConnection(login_filepath)
    out = db_connection.execute_simple(['SHOW TABLE ' + table_name])
    create_stmt = ''
    reading_create_stmt = False
    for line in (line.strip() for line in out.split('\n')):
        if line.startswith('CREATE'):
            reading_create_stmt = True
        if reading_create_stmt:
            create_stmt += line + '\n'
        if line.endswith(';'):
            reading_create_stmt = False
    db_connection.execute_simple(['DROP TABLE ' + table_name, create_stmt])

подскажите, как сделать подобное на основе модуля teradata, а не db


Ответы (0 шт):