Ejemplo n.º 1
0
def __force_teradata_connection():
    args = __parse_args()
    import teradatasql
    teradatasql.connect(None,
                        host=args.teradata_host,
                        user=args.teradata_user,
                        password=args.teradata_pass)
    def __init__(self,
                 host,
                 user_name,
                 password,
                 port=1025,
                 logmech='TD2',
                 use_no_lock_tables=False):
        """Construct a TeradataClient.

        Parameters
        ----------
        host : str
            The Database host to connect to
        user_name : str
            A Database username to connect with
        password : str
            Password for supplied username
        port : Optional[int]
            The database port to connect to (default. 1025)
        logmech : Optional[int]
            The logmech type to connect to (default. TD2)
        """
        self.teradata_config = {
            "host": host,
            "user": user_name,
            "password": password,
            "dbs_port": port,
            "logmech": logmech,
        }

        self.client = teradatasql.connect(**self.teradata_config)
        self.use_no_lock_tables = use_no_lock_tables
Ejemplo n.º 3
0
 def _create_rdbms_connection(self, connection_args):
     # import at the method level, because this flow is conditional
     # if the connector reads from a CSV file, this is not used.
     import teradatasql
     con = teradatasql.connect(None,
                               host=connection_args['host'],
                               user=connection_args['user'],
                               password=connection_args['pass'])
     return con
Ejemplo n.º 4
0
def index():
    target_dbc = None
    if request.method == "GET" and "TARGET_TD_SYSTEM" in request.args:
        target_dbc = escape(request.args.get("TARGET_TD_SYSTEM"))
    if request.method == "POST" and "TARGET_TD_SYSTEM" in request.form:
        target_dbc = escape(request.form.get("TARGET_TD_SYSTEM"))
    if target_dbc:
        admin_userid = current_app.config["ADMIN_USERID"]
        application_database = current_app.config["APPLICATION_DATABASE"]
        password_os_userid = current_app.config["PASSWORD_OS_USERID"]
        password_application = current_app.config["PASSWORD_APPLICATION"]
        passfile = current_app.config["PASSFILE"]
        admin_password = retrieve_password(password_os_userid,
                                           password_application, admin_userid,
                                           target_dbc, passfile)
        target_hostname = target_dbc + "cop1"
        try:
            with teradatasql.connect(host=target_hostname,
                                     user=admin_userid,
                                     password=admin_password) as connection:
                with connection.cursor() as cur:
                    sql = "LOCK ROW FOR ACCESS " \
                          "SELECT " \
                          "UPPER(T.TEST_SET_ID), " \
                          "CAST( T.CREATE_TS AS DATE) (FORMAT \'YYYY-MM-DD\') (CHAR(10)), " \
                          "T.TEST_SET_PURPOSE, " \
                          "EXPIRATION_DATE (FORMAT \'YYYY-MM-DD\') (CHAR(10)) " \
                          "FROM %s.TEST_SET T " \
                          "WHERE T.RESERVED_IND = \'N\' " \
                          "ORDER BY T.TEST_SET_ID;" % application_database
                    try:
                        cur.execute(sql)
                        return render_template("sample.html",
                                               rows=cur.fetchall())
                    except teradatasql.OperationalError as ex:
                        error_message = str(ex)
                        return render_template(
                            "sample.html",
                            error_messages=[
                                'SQL error! %s' %
                                error_message[:error_message.index("\n")],
                                '%s, %s, %s' %
                                (admin_userid, target_dbc, target_hostname),
                                sql
                            ])
        except teradatasql.OperationalError as ex:
            error_message = str(ex)
            return render_template(
                "sample.html",
                error_messages=[
                    'Connection error! %s' %
                    error_message[:error_message.index("\n")],
                    '%s, %s, %s' % (admin_userid, target_dbc, target_hostname)
                ])
    else:
        return render_template("sample.html")
Ejemplo n.º 5
0
 def _connect(self):
     if self.connection is None:
         self.connection = teradatasql.connect(
             host=self.host,
             dbs_port=self.port,
             user=self.username,
             password=self.password,
             logmech=self.authentication,
         )
     return self.connection
    def connect(self):
        host = self.get_host()
        username = self.get_username()
        password = self.get_password()

        connection = teradatasql.connect(None,
                                         host=host,
                                         user=username,
                                         password=password)
        self.set_connection(connection)
Ejemplo n.º 7
0
def teracon(query):

    # thost, tusername, tpassword = '******', 'edw_etl_sandbox', 'Edw$andb0x'
    # query = "select * from edw_target.lh2_app_config_b where app_config_id in (1967,844);"
    with teradatasql.connect(host=db_td['td_host'],
                             user=db_td['td_user'],
                             password=db_td['td_pwd']) as connect:
        df = pd.read_sql(query, connect)
        print(df)
        return df
Ejemplo n.º 8
0
def set_connection(u, pas, h='td2800.corp.tele2.ru'):
    """
    Connect to a Teradata database server

    Parameters:
    -----------
    u - Teradata user;
    pas - Teradata password;
    h - Teradata host;
    """

    return td.connect(None, host=h, user=u, password=pas)
Ejemplo n.º 9
0
def getLName(aadvantageid):
	id ="aadvantageid='"+str(aadvantageid)+"'"
	from dbAccess import selectSQLGen 
	data = {
	'table' : ['users'],
	'values' : ['lastName'],
	'where' : [id]
	}
	statement = selectSQLGen(data)
	import teradatasql
	con = teradatasql.connect('{"host":"168.61.186.29","user":"******","password":"******","dbs_port":"1025"}')
	cur = con.cursor()
	cur.execute(statement)
	return cur.fetchall()
Ejemplo n.º 10
0
def __extract(host, user, password, csv_file_name):
    con = teradatasql.connect(host=host, user=user, password=password)
    cur = con.cursor()

    query = """ SELECT 
                        d.DatabaseName as database_name, d.CreatorName as database_creator, d.OwnerName as database_owner,
                        d.CommentString as database_desc, d.CreateTimeStamp as database_create_time,
                        d.LastAlterTimeStamp as database_update_time,
                        d.LastAlterName as database_update_user,
                        t.TableName as table_name, t.CreatorName as table_creator,
                        t.CommentString as table_desc, t.CreateTimeStamp as table_create_time,
                        t.LastAlterTimeStamp as table_update_time,
                        t.LastAlterName as table_update_user,
                        c.ColumnName as column_name, c.CreatorName as column_creator,
                        c.CommentString as column_desc, c.CreateTimeStamp as column_create_time,
                        c.LastAlterTimeStamp as column_update_time,
                        c.LastAlterName as column_update_user,
                        c.ColumnFormat as column_format, c.ColumnTitle as column_title,
                        c.ColumnType as column_type, c.ColumnLength as column_length,
                        c.DefaultValue as column_default_value, c.Nullable as column_nullable,
                        c.DecimalTotalDigits as column_decimal_total_digits,
                        c.DecimalFractionalDigits as column_decimal_fractional_digits,
                        c.ColumnId as column_id                                           
                    FROM DBC.DatabasesV d
                        JOIN DBC.TablesV t ON t.DataBaseName = d.DataBaseName
                        JOIN DBC.ColumnsV c ON c.TableName = t.TableName
                    WHERE (t.TableKind = 'T' OR t.TableKind = 'V')
                        AND D.DatabaseName NOT IN ('All', 'Crashdumps', 'DBC', 'dbcmngr', 
                            'Default', 'External_AP', 'EXTUSER', 'LockLogShredder', 'PUBLIC', 'SQLJ', 
                            'Sys_Calendar', 'SysAdmin', 'SYSBAR', 'SYSJDBC', 'SYSLIB', 'SYSSPATIAL', 
                            'SystemFe', 'SYSUDTLIB', 'SYSUIF', 'TD_SERVER_DB', 'TD_SYSFNLIB', 
                            'TD_SYSGPL', 'TD_SYSXML', 'TDMaps', 'TDPUSER', 'TDQCD', 'TDStats', 'tdwm')
                    ORDER BY d.DatabaseName, t.TableName, c.columnname;
            """

    # Execute query
    cur.execute(query)

    # Put it all to a data frame
    sql_data = pd.DataFrame(cur.fetchall())
    sql_data.columns = [item[0] for item in cur.description]

    # Close the session
    con.close()

    # Show the data
    logging.info(sql_data.head())

    sql_data.to_csv(csv_file_name, sep=',', encoding='utf-8')
Ejemplo n.º 11
0
def fake_data():
    application_database = 'console'
    fake_table_flag = False
    with teradatasql.connect(host='target_DBCcop1', user='******',
                             password='******') as con:
        with con.cursor() as cur:
            try:
                cur.execute("show table %s.test_set;" % application_database)
            except teradatasql.OperationalError as ex:
                if ("Object '%s.test_set' does not exist." %
                        application_database) in str(ex):
                    try:
                        cur.execute("create multiset table %s.test_set ("
                                    "test_set_id varchar(100), "
                                    "create_ts timestamp, "
                                    "test_set_purpose varchar(100), "
                                    "expiration_date date, "
                                    "reserved_ind varchar(1) "
                                    ");" % application_database)
                        fake_table_flag = True
                        cur.execute(
                            "insert into %s.test_set (?, ?, ?, ?, ?);" %
                            application_database,
                            [[
                                "abc1", "2017-07-11 15:04:00", "abc",
                                "2018-07-11", "N"
                            ],
                             [
                                 "def2", "2016-07-11 15:04:00", "def",
                                 "2017-07-11", "Y"
                             ],
                             [
                                 "abc3", "2014-07-11 15:04:00", "abc",
                                 "2015-07-11", "N"
                             ],
                             [
                                 "def4", "2019-07-11 15:04:00", "def",
                                 "2020-07-11", "N"
                             ]])
                    except teradatasql.OperationalError as ex:
                        print(ex)
            finally:
                yield
                if fake_table_flag:
                    cur.execute("drop table console.test_set;")
Ejemplo n.º 12
0
def queryTeradata(myQuery, user, password):
    """
    Esta función permite hacer consultas tipo SQL a teradata mediante un query, 
    pasando como parametros el user y la contraseña
    establecidos para teradata
    
    Uso: 
        queryTeradata("SELECT * FROM XXXX",  "user", "password")
    """

    import teradatasql
    import pandas as pd

    con = teradatasql.connect(host='10.205.24.12',
                              user=user,
                              password=password)
    df = pd.read_sql(myQuery, con)
    return df
Ejemplo n.º 13
0
 def execute_sql(self):
     with teradatasql.connect(host="192.168.179.128",
                              user='******',
                              password='******') as con:
         # with teradatasql.connect (host=self.dbcname.get(), user=self.db_username.get(), password=self.password.get()) as con:
         with con.cursor() as cur:
             cur.execute(
                 "SELECT S.DataBaseName,S.TableName AS Name, CASE   TableKind WHEN   'O' THEN 'T' WHEN   'D' THEN 'P' WHEN   'E' THEN 'P' WHEN   'A' THEN 'F' WHEN   'S' THEN 'F' WHEN   'R' THEN 'F' WHEN   'B' THEN 'F'  ELSE   TableKind END    AS Typ ,SUM(CurrentPerm)/1024/1024 AS CurrentPermMB,SUM(PeakPerm)/1024/1024 AS PeakPermMB,             (100 - (AVG(CurrentPerm)/NULLIFZERO(MAX(CurrentPerm))*100)) AS SkewFactor,CreatorName,CommentString FROM   Dbc.TableSizeV S,dbc.TablesV T "
                 "WHERE  1=1       AND S.DataBaseName in  ('" +
                 self.database.get() +
                 "')   AND    S.DataBaseName=T.DataBaseName        AND    S.TableName=T.TableName GROUP  BY 1,2,3,7,8 ORDER  BY 1,4 desc;"
             )
             _rs = cur.fetchall()
     # for row in _rs:
     #     print(row)
     self.tree.delete(*self.tree.get_children())
     for row in _rs:
         self.tree.insert('', 'end', values=row)
Ejemplo n.º 14
0
 def run(self, dispatcher: CollectingDispatcher,
         tracker: Tracker,
         domain: Dict[Text, Any]) -> List[Dict[Text, Any]]:
     auth = tweepy.OAuthHandler('SpvZkd6MAEl7cYKqihxI9eX72','XO4LIBymaWT5TVMICP3iluh9muxzk2qAixYu2dVJiSrAzlleqv')
     auth.set_access_token('1105782144566288384-TAWiXN8cZ59fX2cSYPoUvuzg2QZ8wA',
                 'SRe0Wh7wfqtBaic89DbBQVPb0V2qo5aUgSBrI4zUSLsrr')
     api=tweepy.API(auth)
     username = '******'
     con = teradatasql.connect('{"host":"sdt17023.labs.teradata.com", "user":"******", "password":"******"}')
     with con.cursor() as cur:
         rows = cur.execute("select dt1.text, dt1.created_at from ALICE.tweets as dt1, (select max(rt_cnt) as rt_cnt from ALICE.tweets)as dt2 where dt1.rt_cnt = dt2.rt_cnt;")
         reply = ""
         datec = ""
         for row in rows:
             reply = row[0]
             datec = row[1]
             break
     dispatcher.utter_message(text="Here's the tweet with max retweets, \""+reply+"\". Created on, "+datec+"!")
     return []
Ejemplo n.º 15
0
def main(req: func.HttpRequest) -> func.HttpResponse:
    logging.info('Python HTTP trigger function processed a request.')

    con = teradatasql.connect(host="whomooz", user="******", password="******")

    name = req.params.get('name')
    if not name:
        try:
            req_body = req.get_json()
        except ValueError:
            pass
        else:
            name = req_body.get('name')

    if name:
        return func.HttpResponse(f"Hello {name}!")
    else:
        return func.HttpResponse(
            "Please pass a name on the query string or in the request body",
            status_code=400)
Ejemplo n.º 16
0
def gcfr_schema_init():
    global hostn, usern, passw
    sqlScript = """
CREATE DATABASE GCFR_MAIN FROM DBC
AS PERM=200e7
;

create  USER GCFR_USER FROM GCFR_MAIN
AS PASSWORD=ilikecats
   PERM=0
   -- TEMPORARY=1e9
   DEFAULT DATABASE=GCFR_MAIN
   NO FALLBACK
;
GRANT ALL ON GCFR_MAIN TO DBC;
GRANT EXECUTE PROCEDURE ON GCFR_MAIN TO DBC WITH GRANT OPTION;
GRANT UDTUSAGE ON SYSUDTLIB TO GCFR_MAIN WITH GRANT OPTION;
GRANT UDTUSAGE ON SYSUDTLIB TO GCFR_MAIN;
GRANT EXECUTE FUNCTION ON GCFR_MAIN TO GCFR_USER;
GRANT EXECUTE PROCEDURE ON GCFR_MAIN TO GCFR_MAIN WITH GRANT OPTION;
GRANT ALL ON GCFR_MAIN TO GCFR_USER;
grant select on DBC to GCFR_USER with grant option;
grant select on DBC to GCFR_MAIN with grant option;
grant select on SYS_CALENDAR to GCFR_USER with grant option; 
grant EXECUTE PROCEDURE on sqlj to GCFR_USER;
"""

    sqlScriptArray = sqlScript.split(';')
    with teradatasql.connect(host=hostn, user=usern,
                             password=passw) as sessionTD:
        with sessionTD.cursor() as tdCur:
            for x in sqlScriptArray:
                print(x.strip())
                results = []
        for queryline in sqlScriptArray:
            print(queryline.strip())
            tdCur.execute(queryline.strip())
            results += tdCur.fetchall()
        print(results)
Ejemplo n.º 17
0
 def connect(self):
     # type: () -> Iterator[teradatasql.connection]
     conn = None
     if TERADATASQL_IMPORT_ERROR:
         self.log.error(
             'Teradata SQL Driver module is unavailable. Please double check your installation and refer to the '
             'Datadog documentation for more information. %s',
             TERADATASQL_IMPORT_ERROR,
         )
         raise TERADATASQL_IMPORT_ERROR
     self.log.info('Connecting to Teradata database %s on server %s.',
                   self.config.database, self.config.server)
     try:
         conn = teradatasql.connect(self._connect_params)
         self.log.info('Connected to Teradata.')
         yield conn
     except Exception as e:
         self.log.error('Unable to connect to Teradata. %s.', e)
         raise e
     finally:
         if conn:
             conn.close()
def queryTeradataSeguro(myQuery, user):

    import teradatasql
    import pandas as pd
    import os
    """
    Esta función permite hacer consulta SQL a teradata mediante un query, usando el password ecriptado en 
    dos archivos de llaves generados previamente mediante TJEncryptPassword.R
    las llaves que contienen la clave encriptada deben estar en el mismo directorio que el notebook a ejecutar
    
    Uso:
        queryTeradataSeguro("SELECT * FROM XXXX",  "usuario")
    """
    PASS_PATH = os.getenv('HOME')
    PASS_PATH += "/notebooks"
    con = teradatasql.connect(
        host='10.205.24.12',
        user=user,
        password=
        f"ENCRYPTED_PASSWORD(file:{PASS_PATH}/PassKey.properties,file:{PASS_PATH}/EncPass.properties)"
    )
    df = pd.read_sql(myQuery, con)
    return df
Ejemplo n.º 19
0
import teradatasql as tds
import pandas as pd

hostn="192.168.170.128"
usern="dbc"
passw="dbc"

#query blocks

statement="""
select time;
select date;
"""

results=[]
with tds.connect(host=hostn,user=usern,password=passw) as sessionTD:
    with sessionTD.cursor() as tdCur:      
        for query_line in statement.split(';'):
            tdCur.execute(query_line.strip())
            results+=tdCur.fetchall()
print(results)
# os 
import os
from datetime import date, datetime
import timeit

# read hidden login info; not the best way to do this but it works
login = [line.rstrip('\n') for line in open('login.txt')]

# new connection info for teradatasql client
usertd = login[2]
passwordtd = login[3]
host = login[4]

# create connection to teradata
con = teradatasql.connect('{"host": "' + host + '",' + \
                          '"user": "******",' + \
                          '"password": "******",' + \
                          '"logmech":"LDAP"}')


# create cursor to submit scripts
cur = con.cursor()

print(    
"""
This script joins the visits with flare (ibd_flare.flare_vists) table with 
any prescription of immuosuppresive medications at or before visit temp table, 
demographics table, and baseline and categorical labs summary together. It then
subsets only to patient visits with at least one lab measurement. The final step
is to save a permanent table and csv file.
"""
)
Ejemplo n.º 21
0
# Copyright 2020 by Teradata Corporation. All rights reserved.

# This sample program demonstrates how to FastExport rows from a table.

import teradatasql

with teradatasql.connect(host="whomooz", user="******",
                         password="******") as con:
    with con.cursor() as cur:
        with con.cursor() as cur2:
            sTableName = "FastExportTable"
            try:
                sRequest = "DROP TABLE " + sTableName
                print(sRequest)
                cur.execute(sRequest)
            except Exception as ex:
                print("Ignoring", str(ex).split("\n")[0])

            sRequest = "CREATE TABLE " + sTableName + " (c1 INTEGER NOT NULL, c2 VARCHAR(10))"
            print(sRequest)
            cur.execute(sRequest)

            try:
                sInsert = "INSERT INTO " + sTableName + " VALUES (?, ?)"
                print(sInsert)
                cur.execute(sInsert, [
                    [1, None],
                    [2, "abc"],
                    [3, "def"],
                    [4, "mno"],
                    [5, None],
Ejemplo n.º 22
0
                node=dict(pad=15,
                          thickness=20,
                          line=dict(color="black", width=0.5),
                          label=labelList,
                          color=colorList),
                link=dict(source=sourceTargetDf['sourceID'],
                          target=sourceTargetDf['targetID'],
                          value=sourceTargetDf['count']))

    layout = dict(title=title, font=dict(size=10))

    fig = dict(data=[data], layout=layout)
    return fig


con = tdsql.connect(host="192.168.100.162", user="******", password="******")
cus = con.cursor()


def sql_icld_cols(sql):
    cus.execute(sql)
    rst_no_cols = cus.fetchall()
    cols_des = cus.description

    col = []  # 创建一个空列表以存放列名
    for v in cols_des:
        col.append(v[0])  # 循环提取列名,并添加到col空列表
    dfsql = pd.DataFrame(rst_no_cols, columns=col)  # 将查询结果转换成DF结构,并给列重新赋值
    if dfsql.empty:
        return 'empty set'
    else:
# https://pypi.org/project/teradatasql/#SamplePrograms
import teradatasql
con = teradatasql.connect(host="host", user="******", password="******")
cur = con.cursor()
"""Query and display the results"""


def executeQuery(query):
    cur.execute(query)
    #print(cur.description, "\n")
    for col in cur.description:
        print(col[0], " | ", end="")
    print()
    #print("\n", cur.fetchmany(10))
    list = cur.fetchmany(5)
    for row in list:
        for col in row:
            print(col, " | ", end='')
        print()


executeQuery("SELECT * FROM BASE_PORTAL.MASTER_TABLE")
Ejemplo n.º 24
0
def cur_execute(cur, sSQL, params=None):
    print()
    print("cur.execute", sSQL, "bound values", params)
    cur.execute(sSQL, params)
    DisplayResults(cur)


def cur_callproc(cur, sProcName, params=None):
    print()
    print("cur.callproc", sProcName, "bound values", params)
    cur.callproc(sProcName,
                 params)  # OUT parameters are not supported by .callproc
    DisplayResults(cur)


with teradatasql.connect(
        '{"host":"whomooz","user":"******","password":"******"}') as con:
    with con.cursor() as cur:

        # Demonstrate a stored procedure having IN and INOUT parameters.
        # Returns one result set having one row and one column containing the output parameter value.

        cur.execute(
            "replace procedure examplestoredproc (in p1 integer, inout p2 integer) begin set p2 = p1 + p2 ; end ;"
        )
        try:
            cur_execute(
                cur,
                "{call examplestoredproc (3, 5)}")  # literal parameter values
            cur_execute(cur, "{call examplestoredproc (?, ?)}",
                        [10, 7])  # bound parameter values
            cur_callproc(cur, "examplestoredproc",
Ejemplo n.º 25
0
from teradataml.dataframe.copy_to import copy_to_sql
from teradataml.context.context import create_context, remove_context, get_connection, get_context
from teradataml.options.display import display
from teradataml.dataframe.fastload import fastload
#import tdconnect
import getpass
import datetime
from datetime import date
from datetime import datetime, timedelta
from datetime import datetime
from teradataml.context.context import *
import ssl
import teradatasql
ssl._create_default_https_context = ssl._create_unverified_context
import params
con = teradatasql.connect(host=params.MyHost, user=params.MyUser, password=params.Password,logmech=params.LogMech,tmode='TERA')

#############################################################
# Stage to Core Loads
#############################################################

with con.cursor () as cur:
    # Core Load Calls to Teradata
    cur.execute ("CALL "+params.SchemaName+".ETL_CUST_DATA_CORE (v_MsgTxt,v_RowCnt,v_ResultSet);")
    from datetime import datetime
    datetime.utcnow()
    dateTimeObj = pytz.utc.localize(datetime.utcnow()).astimezone(pytz.timezone('US/Pacific'))
    timestampStr = dateTimeObj.strftime("%d-%b-%Y (%H:%M:%S.%f)")
    print("ETL_CUST_DATA_CORE Finished!  " + timestampStr)

    cur.execute ("CALL "+params.SchemaName+".ETL_LOOKUP_CORE (v_MsgTxt,v_RowCnt,v_ResultSet);")
Ejemplo n.º 26
0
def get_conn(connection_args):
    return connect(None,
                   host=connection_args['host'],
                   user=connection_args['user'],
                   password=connection_args['pass'])
 def create_connection():
     cursor = teradatasql.connect(host='td........org',
                                  user=credentials.short_name_usr_ntid,
                                  password=credentials.user_ntid_pswrd,
                                  logmech="LDAP")
     return cursor
Ejemplo n.º 28
0
#File AAcares.py

#Establish Database Connection
import teradatasql
con = teradatasql.connect(
    '{"host":"168.61.186.29","user":"******","password":"******","dbs_port":"1025"}'
)
cur = con.cursor()
Ejemplo n.º 29
0
'''
Created on Mar 7, 2019

@author: vkhoday
'''

import teradata as td
import pandas as pd
import teradatasql as tds
from PIL import Image, ImageDraw

with tds.connect('{"host":"localhost","user":"******","password":"******"}') as con:
    with con.cursor() as cur:
        cur.execute('select * from tabs')
        row = cur.fetchall()
# driver=webdriver.phan
Ejemplo n.º 30
0
def gcfr_schema_decommission(db_admin_user, parent_schema, schema_prefix):
    global hostn, usern, passw
    sqlScript = """
                            delete DATABASE """ + schema_prefix + """M_OPR;
                            drop database """ + schema_prefix + """M_OPR ;
                            delete database """ + schema_prefix + """T_OPR;
                            drop database """ + schema_prefix + """T_OPR;
                            delete database """ + schema_prefix + """V_OPR ;
                            drop database """ + schema_prefix + """V_OPR ;
                            delete database """ + schema_prefix + """_OPR; 
                            drop database """ + schema_prefix + """_OPR;
                            drop user """ + schema_prefix + """_ETL_USR;
                            delete DATABASE """ + schema_prefix + """V_SEM ;
                            drop DATABASE """ + schema_prefix + """V_SEM ;
                            delete DATABASE """ + schema_prefix + """T_SEM ;
                            drop DATABASE """ + schema_prefix + """T_SEM ;
                            delete DATABASE """ + schema_prefix + """_SEM ;
                            drop DATABASE """ + schema_prefix + """_SEM ;
                            delete DATABASE """ + schema_prefix + """V_OUT ;
                            drop DATABASE """ + schema_prefix + """V_OUT ;
                            delete DATABASE """ + schema_prefix + """V_INP ;
                            drop DATABASE """ + schema_prefix + """V_INP ;
                            delete DATABASE """ + schema_prefix + """_TXFM ;
                            drop DATABASE """ + schema_prefix + """_TXFM ;
                            delete DATABASE """ + schema_prefix + """V_UTLFW; 
                            drop DATABASE """ + schema_prefix + """V_UTLFW ;
                            delete DATABASE """ + schema_prefix + """T_UTLFW ;
                            drop DATABASE """ + schema_prefix + """T_UTLFW ;
                            delete DATABASE """ + schema_prefix + """_UTLFW; 
                            drop DATABASE """ + schema_prefix + """_UTLFW ;
                            delete database """ + schema_prefix + """V_SRCI ;
                            drop database """ + schema_prefix + """V_SRCI ;
                            delete DATABASE """ + schema_prefix + """T_SRCI ;
                            drop DATABASE """ + schema_prefix + """T_SRCI ;
                            delete DATABASE """ + schema_prefix + """_SRCI ;
                            drop DATABASE """ + schema_prefix + """_SRCI ;
                            delete DATABASE """ + schema_prefix + """V_STG ;
                            drop DATABASE """ + schema_prefix + """V_STG ;
                            delete DATABASE """ + schema_prefix + """T_STG ;
                            drop DATABASE """ + schema_prefix + """T_STG ;
                            delete DATABASE """ + schema_prefix + """_STG ;
                            drop DATABASE """ + schema_prefix + """_STG ;
                            delete DATABASE """ + schema_prefix + """T_WRK ;
                            drop DATABASE """ + schema_prefix + """T_WRK ;
                            delete DATABASE """ + schema_prefix + """T_TMP ;
                            drop DATABASE """ + schema_prefix + """T_TMP ;
                            delete DATABASE """ + schema_prefix + """_TMP ;
                            drop DATABASE """ + schema_prefix + """_TMP;
                            delete DATABASE """ + schema_prefix + """P_PP ;
                            drop DATABASE """ + schema_prefix + """P_PP ;
                            delete DATABASE """ + schema_prefix + """P_CP ;
                            drop DATABASE """ + schema_prefix + """P_CP ;
                            delete DATABASE """ + schema_prefix + """P_FF ;
                            drop DATABASE """ + schema_prefix + """P_FF ;
                            delete DATABASE """ + schema_prefix + """P_UT ;
                            drop DATABASE """ + schema_prefix + """P_UT ;
                            delete DATABASE """ + schema_prefix + """P_BB ;
                            drop DATABASE """ + schema_prefix + """P_BB ;
                            delete DATABASE """ + schema_prefix + """P_API ;
                            drop DATABASE """ + schema_prefix + """P_API ;
                            delete DATABASE """ + schema_prefix + """M_GCFR ;
                            drop DATABASE """ + schema_prefix + """M_GCFR ;
                            delete DATABASE """ + schema_prefix + """V_GCFR ;
                            drop DATABASE """ + schema_prefix + """V_GCFR ;
                            delete DATABASE """ + schema_prefix + """T_GCFR ;
                            drop DATABASE """ + schema_prefix + """T_GCFR ;
                            delete DATABASE """ + schema_prefix + """_GCFR ;
                            drop DATABASE """ + schema_prefix + """_GCFR ;
                            delete DATABASE """ + schema_prefix + """V_BASE ;
                            drop DATABASE """ + schema_prefix + """V_BASE ;
                            delete DATABASE """ + schema_prefix + """T_BASE ;
                            drop DATABASE """ + schema_prefix + """T_BASE ;
                            delete DATABASE """ + schema_prefix + """_BASE ;
                            drop DATABASE """ + schema_prefix + """_BASE ;
                            delete database """ + parent_schema + """;
                            delete user """ + db_admin_user + """;
                            drop user """ + db_admin_user + """;
                            drop database """ + parent_schema + """;
"""

    sqlScriptArray = sqlScript.split(';')
    with teradatasql.connect(host=hostn, user=usern,
                             password=passw) as sessionTD:
        with sessionTD.cursor() as tdCur:
            for x in sqlScriptArray:
                print(x.strip())
                results = []
        for queryline in sqlScriptArray:
            print(queryline.strip())
            tdCur.execute(queryline.strip())
            results += tdCur.fetchall()
        pprint(results)