good morning.
i have an odbc connect to a mssql db... it works and it looks like this:
views-----------------------------------
def kundendaten(request):
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=MAURITIUS;DATABASE=baan5c;UID=***;PWD=*****')
cursor = cnxn.cursor()
cursor.execute("SELECT x.t_name, y.t_mail FROM tttaad200000 as x, tttcmf200000 as y WHERE (x.t_name = y.t_name)")
row = cursor.fetchall()
return render_to_response("kundendaten.html", { 'row': row }, context_instance=RequestContext(request))
-------------------------------------------
what does it do? it gives out the name and the e-mail of a customer. the values are from two tables together and with "WHERE (x.t_name = y.t_name)" i avoid redundancy.
here the output of these request:
-------------------------------------------
[('Ackermann Marcel (THA) ', 'marcel.***@***.ch '), ('Adami Renate (HEI) ', 'renate.***@***.ch '), ('Ammann Cornelia (HEI) ', 'cornelia.***@***.ch '), ('Ausbildung A. Schwaller (HEI) ', 'giulia.***@***.ch '), ('General_User_NT (SYS) ', 'baan-alarm@***.ch '), ('Benz Roger (THA) ', 'roger.***@***.ch '), ('Berktold Stefan (THA) ', 'stefan.***@***.ch '), ('Biegger Christian (THA) ')]
-------------------------------------------
and now my problem... i dont know how that i can give it out into a table. i createt a modul:
modul-----------------------------------
from django.db import models
class Person(models.Model):
t_name = models.CharField(max_length=30)
t_mail = models.CharField(max_length=30)
--------------------------------------------
i dont know whether i need this and i dont know how to use the table, that it works...
can anyone help me pls. (if its possible pls not just text how to do, im very new and i can learn more when i see a correct code)