I'm trying to clean a list that is essentially a Table definition I pulled from Teradata DB using SQLAlchemy. I'm essentially trying to replace the \r character from the string
I've tried using the replace function in a for loop as shown below
import teradata
import sqlalchemy
import string
eng = sqlalchemy.create_engine('teradatasql:///?user=xxxx&
# execute sql
query = 'SHOW TABLE DBADMIN_BKP.LIKP_BKP'
result = eng.execute(query)
results = result.fetchall()
results = [items.replace("\n", "") for items in results]
print (results)
Traceback (most recent call last):
File "SQL_ALCHEMY.py", line 12, in <module>
results = [items.str_replace("\n", "") for items in results]
File "SQL_ALCHEMY.py", line 12, in <listcomp>
results = [items.str_replace("\n", "") for items in results]
AttributeError: Could not locate column in row for column 'replace'
itemsis a string? I would suggest inspecting what the elements ofresultsactually are.itemsto be sure of what you're doing?