Hello, i know I have asked this before in another post of me, but no one answered on it and it was not part of topic...
I am using pyodbc and try to give data out into my page...
Here the part of pyodbc (and yes this works):
views---------------------------------------------------------
.....
1 conn = pyodbc.connect('DRIVER={SQL Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*****')
2 cursor = conn.cursor()
3 cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad200000 as x, tttcmf200000 as y WHERE (x.t_name = y.t_name)")
4 row = cursor.fetchall()
5
6 return render_to_response("kundendaten.html", { 'row': row}, context_instance=RequestContext(request))
.....
-----------------------------------------------------------------
On line number 4 you can see now, there is "row = cursor.fetchall()"... When i give out this part now i become two outputs, (one without formatting to see what value i become, the other have to be in a table)
Here the parts of my website:
Kundendaten-------------------------------------
.....
{% block content2 %}Kundendaten{{ row }}.{% endblock %}
.....
<tr>
<th>Name</th>
<th>Mail</th>
</tr>
{% for t_user in row %}
<tr>
<td>{{ row.t_name }}</td>
<td>{{ row.t_mail }}</td>
</tr>
{% endfor %}
.....
------------------------------------------------------
1.:
[('Ackermann Marcel (THA) ', 'marcel.ackermann@***.ch '), ('Adami Renate (HEI) ', 'renate.adami@*.ch '), ('Ammann Cornelia (HEI) ', 'cornelia.ammann@*.ch '), ('Ausbildung A. Schwaller (HEI) ', 'giulia.franco@*.ch '), ('General_User_NT (SYS) ', 'baan-alarm@*.ch '), ('Benz Roger (THA) ', 'roger.benz@*.ch '), .....
2.:
(A table with only name and mail as colum titles and but 2 empty lines)
When i add now on line 3 by views t_user like this:
3 cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad200000 as x, tttcmf200000 as y WHERE (x.t_name = y.t_name)")
I become a longer output... and a table with 3 empty lines
When i use it now with fetchone and two selects:
4 row = cursor.fetchone()
I become a table like this:
Name | Mail |
---|
Ackermann Marcel (THA) | marcel.ackermann@***.ch |
Ackermann Marcel (THA) | marcel.ackermann@***.ch |
And with tree selects there will be tree lines with same value...
Now my question:
How can i make my output correct with fetchall that i can see all lines with the correct values?