from sqlalchemy import create_engine
engine = create_engine('mssql+pymssql://myusername:[email protected]:1433/AQOA_Core')
connection = engine.connect()
result = connection.execute("""SELECT DISTINCT Distributor FROM Product""")
for row in result:
print row[0]
connection.close()
The above code returns a result set as:
FRANCETV
GAUMONT
M6SND
PATHE
STUDIOCANAL
TF1
WARNER
What if I want to print just one value without changing the query?
Tried print row[0][1], print row[0:1] This was tried to print just the first value FRANCETV
Basically I want to be able to print each one of the values in the result set seperately without making changes to the query.
print result[0][0]return?S E G G W O M Traceback (most recent call last): File "connect.py", line 6, in <module> print row[0][0] TypeError: 'NoneType' object has no attribute '__getitem__'