kandi background
kandi background
Explore Kits
kandi background
Explore Kits
kandi background
Explore Kits
kandi background
Explore Kits
Explore all Data Migration open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Data Migration

GA release v1.1.4

3.5.0

0.12.10

v3.5.3

Version 3.1.1

gh-ost

GA release v1.1.4

migrations

3.5.0

phinx

0.12.10

goose

v3.5.3

mara-pipelines

Version 3.1.1

Popular Libraries in Data Migration

Trending New libraries in Data Migration

Top Authors in Data Migration

1

15 Libraries

840

2

6 Libraries

43

3

4 Libraries

22

4

4 Libraries

38

5

4 Libraries

70

6

3 Libraries

115

7

3 Libraries

55

8

3 Libraries

18

9

3 Libraries

2039

10

3 Libraries

11

1

15 Libraries

840

2

6 Libraries

43

3

4 Libraries

22

4

4 Libraries

38

5

4 Libraries

70

6

3 Libraries

115

7

3 Libraries

55

8

3 Libraries

18

9

3 Libraries

2039

10

3 Libraries

11

Trending Kits in Data Migration

No Trending Kits are available at this moment for Data Migration

Trending Discussions on Data Migration

    Download DML and DDL sql from Teradata using python
    Cosmos DB REPLACE strings in nested Object
    FastAPI refuses to let me create a mongoengine document
    How to deal with missing columns on old data migrations?
    Alternative Syntax or Logic for AngularFireStore Update?
    How to maintain a table of all proxy models in Django?
    How to abandon a manual Room migration script, and fall back to destructive migration?
    Copy SQL Server Scheduled Jobs to Oracle Scheduler
    Using SchemaCrawler API to get Weak/Implied Relationships
    MySQL idempotent version of add column failing

QUESTION

Download DML and DDL sql from Teradata using python

Asked 2022-Mar-23 at 11:14

What approach should I follow to download DDL, DML and Stored Procedures from the teradata database using python.

I have created the sample code but what is the approach to download these sql files for data migration process.

1udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=False)
2session = udaExec.connect(method="odbc", system="xxx",username="xxx", password="xxx");
3for row in session.execute("show tables {} > {}".format(tables, export_tables)):
4     print(row)
5

Unlike MSSQL which had mssql-scripter to download .sql files, does teradata provide any such option to download. Also, does it provide support to download sequences, views and procedures ?

For the Schema Migration process, what should be the best approach to download these files from the teradata as a source ?

ANSWER

Answered 2022-Mar-23 at 11:14

Happy to share that I got the solution for this approach. In order to get the files in sql format use the given code to extract DDL and DML Code.

The given code is for sample database dbc.

copy icondownload icon

1udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=False)
2session = udaExec.connect(method="odbc", system="xxx",username="xxx", password="xxx");
3for row in session.execute("show tables {} > {}".format(tables, export_tables)):
4     print(row)
5with teradatasql.connect(host='enter_host_ip', user='---', password='---') as connect:
6#get the table name and database name in csv file using select statement
7df = pd.read_csv("result.csv", index_col=None)
8for tables_name in df['TableName']:
9    query = "SHOW TABLE DBC."+ tables_name
10    try:
11        df = pd.read_sql(query, connect)
12        df1 = df['Request Text'][0]
13        writePath = "C:\\Users\\SQL\\"+tables_name+".sql"
14        with open(writePath, 'a') as f:
15            dfAsString = df1
16            f.write(dfAsString)
17    except Exception as e1:
18        print(tables_name)            
19        pass
20

Note : Out of 192 tables I was able to get DDL/DML scripts for 189 tables. For tables perform manual intervention.

Source https://stackoverflow.com/questions/70331340

Community Discussions contain sources that include Stack Exchange Network

    Download DML and DDL sql from Teradata using python
    Cosmos DB REPLACE strings in nested Object
    FastAPI refuses to let me create a mongoengine document
    How to deal with missing columns on old data migrations?
    Alternative Syntax or Logic for AngularFireStore Update?
    How to maintain a table of all proxy models in Django?
    How to abandon a manual Room migration script, and fall back to destructive migration?
    Copy SQL Server Scheduled Jobs to Oracle Scheduler
    Using SchemaCrawler API to get Weak/Implied Relationships
    MySQL idempotent version of add column failing

QUESTION

Download DML and DDL sql from Teradata using python

Asked 2022-Mar-23 at 11:14

What approach should I follow to download DDL, DML and Stored Procedures from the teradata database using python.

I have created the sample code but what is the approach to download these sql files for data migration process.

1udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=False)
2session = udaExec.connect(method="odbc", system="xxx",username="xxx", password="xxx");
3for row in session.execute("show tables {} > {}".format(tables, export_tables)):
4     print(row)
5

Unlike MSSQL which had mssql-scripter to download .sql files, does teradata provide any such option to download. Also, does it provide support to download sequences, views and procedures ?

For the Schema Migration process, what should be the best approach to download these files from the teradata as a source ?

ANSWER

Answered 2022-Mar-23 at 11:14

Happy to share that I got the solution for this approach. In order to get the files in sql format use the given code to extract DDL and DML Code.

The given code is for sample database dbc.

copy icondownload icon

1udaExec = teradata.UdaExec(appName="HelloWorld", version="1.0",logConsole=False)
2session = udaExec.connect(method="odbc", system="xxx",username="xxx", password="xxx");
3for row in session.execute("show tables {} > {}".format(tables, export_tables)):
4     print(row)
5with teradatasql.connect(host='enter_host_ip', user='---', password='---') as connect:
6#get the table name and database name in csv file using select statement
7df = pd.read_csv("result.csv", index_col=None)
8for tables_name in df['TableName']:
9    query = "SHOW TABLE DBC."+ tables_name
10    try:
11        df = pd.read_sql(query, connect)
12        df1 = df['Request Text'][0]
13        writePath = "C:\\Users\\SQL\\"+tables_name+".sql"
14        with open(writePath, 'a') as f:
15            dfAsString = df1
16            f.write(dfAsString)
17    except Exception as e1:
18        print(tables_name)            
19        pass
20

Note : Out of 192 tables I was able to get DDL/DML scripts for 189 tables. For tables perform manual intervention.

Source https://stackoverflow.com/questions/70331340