vzhledem k tomu ze se jedna o vytvoreni opravdu maleho a pokud mozno autonomniho meziclanku v DI procesu. Iron python asi nebude ono; ale rozhodne si to zkusim.<br><br><div class="gmail_quote">2009/5/5 <span dir="ltr"><<a href="mailto:RMiklos@pss.sk">RMiklos@pss.sk</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><font size="2" face="sans-serif">Ked su na to SQL-prikazy mohlo by to fungovat.</font>
<br><font size="2" face="sans-serif">Mimochodom ked som zadal do Googlu </font><a href="http://www.google.sk/search?hl=sk&q=data+relation+ADO&meta=&aq=f&oq=" target="_blank"><font size="2" face="sans-serif">http://www.google.sk/search?hl=sk&q=data+relation+ADO&meta=&aq=f&oq=</font></a>
<br><font size="2" face="sans-serif">tak mi to vyhodilo same linky suvisiace
s <a href="http://ADO.NET" target="_blank">ADO.NET</a> - napriklad tu </font>
<br>
<br><a href="http://www.c-sharpcorner.com/UploadFile/cvinodkumar/DataRelationVK11292005072318AM/DataRelationVK.aspx" target="_blank"><font size="2" face="sans-serif">http://www.c-sharpcorner.com/UploadFile/cvinodkumar/DataRelationVK11292005072318AM/DataRelationVK.aspx</font></a>
<br>
<br><font size="2" face="sans-serif">Predpokladam, ze ADO na to nema metody,
iba <a href="http://ADO.NET" target="_blank">ADO.NET</a>.</font>
<br>
<br><font size="2" face="sans-serif"><a href="http://ADO.NET" target="_blank">ADO.NET</a> je odlisne od ADO. Napriklad
namiesto objektu Recordset sa pouziva DataSet, ktory moze obsahovat viac
tabuliek. </font>
<br><font size="2" face="sans-serif">Ale na vytvorenie relacie ma objekt
typu DataSet metodu </font><font size="2" face="Verdana">(ako vidiet na priklade
v horeuvedenom linku: </font>
<form action="http://www.c-sharpcorner.com/UploadFile/cvinodkumar/DataRelationVK11292005072318AM/DataRelationVK.aspx" method="post" target="_blank" onsubmit="return window.confirm("Odesíláte informace na externí stránku.\nJste si jisti?");">
<font size="2" face="Verdana">DataSet.Relations.Add()
)</font>
<br>
<br><font size="2" face="sans-serif"><a href="http://ADO.NET" target="_blank">ADO.NET</a> som skusal s IronPythonom (
</font><a href="http://www.codeplex.com/IronPython" target="_blank"><font size="2" face="sans-serif">http://www.codeplex.com/IronPython</font></a><font size="2" face="sans-serif">
). </font>
<br><font size="2" face="sans-serif">Ak by si to chcel skusit s IronPythonom,
tak tu je maly zdrojak jak sa s tym robi, Zvysok odkukas zo zdrojakov C#
alebo <a href="http://VB.NET" target="_blank">VB.NET</a></font>
<br><font size="2" face="sans-serif">(Negarantujem ci zdrojak 100% funguje,
lebo teraz IronPython nainstalovany nemam).</font>
<br>
<br>
<br><tt><font size="3">"""</font></tt><tt><font size="3" color="#ff00ff"><br>
Pouzitie <a href="http://ADO.NET" target="_blank">ADO.NET</a> pre pristup do AS/400<br>
s vyuzitim DataSet a DataAdapter</font></tt><tt><font size="3"><br>
"""<br>
csebk ='</font></tt><tt><font size="3" color="#ff00ff">nejaka_as400</font></tt><tt><font size="3">'<br>
userid='</font></tt><tt><font size="3" color="#ff00ff">nejake_id</font></tt><tt><font size="3">'<br>
pwd ='</font></tt><tt><font size="3" color="#ff00ff">nejake_heslo</font></tt><tt><font size="3">'<br>
</font></tt><tt><font size="3" color="blue"><br>
### Pouzitie <a href="http://ADO.NET" target="_blank">ADO.NET</a></font></tt><tt><font size="3" color="#8100ff"><br>
import</font></tt><tt><font size="3"> clr</font></tt><tt><font size="3" color="#8100ff"><br>
import</font></tt><tt><font size="3"> System<br>
clr.AddReference("</font></tt><tt><font size="3" color="#ff00ff">System.Data</font></tt><tt><font size="3">")</font></tt><tt><font size="3" color="#8100ff"><br>
import</font></tt><tt><font size="3"> System.Data<br>
</font></tt><tt><font size="3" color="#8100ff"><br>
from</font></tt><tt><font size="3"> System.Data.OleDb </font></tt><tt><font size="3" color="#8100ff">import</font></tt><tt><font size="3"> OleDbConnection
</font></tt><tt><font size="3" color="#8100ff">as</font></tt><tt><font size="3"> dbconnection</font></tt><tt><font size="3" color="#8100ff"><br>
from</font></tt><tt><font size="3"> System.Data.OleDb </font></tt><tt><font size="3" color="#8100ff">import</font></tt><tt><font size="3"> OleDbDataAdapter
</font></tt><tt><font size="3" color="#8100ff">as</font></tt><tt><font size="3"> dbdataadapter</font></tt><tt><font size="3" color="#8100ff"><br>
from</font></tt><tt><font size="3"> System.Data </font></tt><tt><font size="3" color="#8100ff">import</font></tt><tt><font size="3"> DataSet
</font></tt><tt><font size="3" color="#8100ff">as</font></tt><tt><font size="3"> dataset<br>
</font></tt><tt><font size="3" color="blue"><br>
# Connection String</font></tt><tt><font size="3"><br>
connectstr='</font></tt><tt><font size="3" color="#ff00ff">PROVIDER=IBMDA400.DataSource.1;DATA
SOURCE=</font></tt><tt><font size="3">'+csebk+'</font></tt><tt><font size="3" color="#ff00ff">;
USER ID=</font></tt><tt><font size="3">'+userid+'</font></tt><tt><font size="3" color="#ff00ff">;
PASSWORD=</font></tt><tt><font size="3">'+pwd</font></tt><tt><font size="3" color="blue"><br>
#print connectstr</font></tt><tt><font size="3"><br>
</font></tt><tt><font size="3" color="blue"><br>
# Vytvorit spojenie</font></tt><tt><font size="3"><br>
dbconn=dbconnection(connectstr)<br>
dbconn.Open()<br>
</font></tt><tt><font size="3" color="blue"><br>
# Vytvorit SQL Statement</font></tt><tt><font size="3"><br>
sqlStatement = "</font></tt><tt><font size="3" color="#ff00ff">SELECT
* FROM r000100T.r000270V</font></tt><tt><font size="3">"</font></tt><tt><font size="3" color="blue"><br>
#sqlStatement = "SELECT * FROM r000100T.p400100v"<br>
# DataAdapter</font></tt><tt><font size="3"><br>
da = dbdataadapter(sqlStatement, dbconn)<br>
</font></tt><tt><font size="3" color="blue"><br>
# Vytvorit DataSet<br>
#ds = System.Data.DataSet("MyDataSet")</font></tt><tt><font size="3"><br>
ds=dataset("</font></tt><tt><font size="3" color="#ff00ff">MyDataSet</font></tt><tt><font size="3">")<br>
</font></tt><tt><font size="3" color="blue"><br>
# Naplnit Dataset</font></tt><tt><font size="3"><br>
da.Fill(ds, "</font></tt><tt><font size="3" color="#ff00ff">MyTable</font></tt><tt><font size="3">")<br>
</font></tt><tt><font size="3" color="blue"><br>
# Vylistovat tabulky v DataSete</font></tt><tt><font size="3" color="#813f62"><b><br>
for</b></font></tt><tt><font size="3"> table </font></tt><tt><font size="3" color="#813f62"><b>in</b></font></tt><tt><font size="3"> ds.Tables:<br>
</font></tt><tt><font size="3" color="#813f62"><b>print</b></font></tt><tt><font size="3"> table<br>
</font></tt><tt><font size="3" color="blue"><br>
# Vylistovat vybrane polia vo vsetkych riadkoch 1.tabulky DataSetu</font></tt><tt><font size="3"><br>
count=0</font></tt><tt><font size="3" color="#813f62"><b><br>
for</b></font></tt><tt><font size="3"> row </font></tt><tt><font size="3" color="#813f62"><b>in</b></font></tt><tt><font size="3"> ds.Tables[0].Rows:<br>
count +=1<br>
</font></tt><tt><font size="3" color="#813f62"><b>print</b></font></tt><tt><font size="3"> "</font></tt><tt><font size="3" color="#ff00ff">%10s
%10s %10s %10s</font></tt><tt><font size="3">" % (row[0], row[1],
row[2], row[3])<br>
</font></tt><tt><font size="3" color="#813f62"><b><br>
print</b></font></tt><tt><font size="3"> "</font></tt><tt><font size="3" color="#ff00ff">pocet
viet v tabulke je: %d</font></tt><tt><font size="3">" % count<br>
</font></tt><tt><font size="3" color="blue"><br>
# Ukoncit spojenie</font></tt><tt><font size="3"><br>
dbconn.Close()</font></tt>
<br>
<br>
<br><font size="2" face="sans-serif"><br>
</font>
<br>
<br>
<br>
<table width="100%">
<tbody><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">From:</font>
</td><td><div class="im"><font size="1" face="sans-serif">Ondrej Beranek <<a href="mailto:rainbof@gmail.com" target="_blank">rainbof@gmail.com</a>></font>
</div></td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">To:</font>
</td><td><div class="im"><font size="1" face="sans-serif">Konference PyCZ <<a href="mailto:python@py.cz" target="_blank">python@py.cz</a>></font>
</div></td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Date:</font>
</td><td><font size="1" face="sans-serif">05.05.2009 17:58</font><div><div></div><div class="h5">
</div></div></td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Subject:</font>
</td><td><font size="1" face="sans-serif">Re: [python] access soubor - vytvoření
relací</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Sent by:</font>
</td><td><font size="1" face="sans-serif"><a href="mailto:python-bounces@py.cz" target="_blank">python-bounces@py.cz</a></font></td></tr></tbody></table><div><div></div><div class="h5">
<br>
<hr noshade>
<br>
<br>
<br><font size="3">Uz to odkoukavam tady:<br>
</font><font size="3" color="blue"><u><br>
</u></font><a href="http://msdn.microsoft.com/en-us/library/bb243835.aspx" target="_blank"><font size="3" color="blue"><u>http://msdn.microsoft.com/en-us/library/bb243835.aspx</u></font></a><font size="3"><br>
<br>
pokusim se to tam naprat jako sadu SQL prikazu.<br>
</font>
<br><font size="3">2009/5/5 <</font><a href="mailto:RMiklos@pss.sk" target="_blank"><font size="3" color="blue"><u>RMiklos@pss.sk</u></font></a><font size="3">></font>
<br><font size="2" face="sans-serif">Jake relacie myslis? </font><font size="3">
</font><font size="2" face="sans-serif"><br>
S Accessom nepracujem, ale ak to co chces ide vseobecne cez ADO, tak sa
to da odkukat z nejakych prikladov napr. vo Visual Basicu a malo by to
fungovat aj v Pythone podobnym sposobom. </font><font size="3"><br>
<br>
<br>
<br>
</font>
<table width="100%">
<tbody><tr valign="top">
<td width="17%"><font size="1" color="#5f5f5f" face="sans-serif">From:</font><font size="3">
</font>
</td><td width="82%"><font size="1" face="sans-serif">Ondrej Beranek <</font><a href="mailto:rainbof@gmail.com" target="_blank"><font size="1" color="blue" face="sans-serif"><u>rainbof@gmail.com</u></font></a><font size="1" face="sans-serif">></font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">To:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">Konference PyCZ <</font><a href="mailto:python@py.cz" target="_blank"><font size="1" color="blue" face="sans-serif"><u>python@py.cz</u></font></a><font size="1" face="sans-serif">></font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Date:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">05.05.2009 17:03</font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Subject:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">Re: [python] access soubor - vytvoření
relací</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Sent by:</font><font size="3">
</font>
</td><td><a href="mailto:python-bounces@py.cz" target="_blank"><font size="1" color="blue" face="sans-serif"><u>python-bounces@py.cz</u></font></a></td></tr></tbody></table>
<br><font size="3"><br>
</font>
<hr noshade><font size="3"><br>
<br>
<br>
Přes ADO to vypadá jednoduše. Nenašel jsem ale způsob jak to donutit
tvořit relace mezi tabulkami.<br>
<br>
2009/5/5 <</font><a href="mailto:RMiklos@pss.sk" target="_blank"><font size="3" color="blue"><u>RMiklos@pss.sk</u></font></a><font size="3">>
</font><font size="2" face="sans-serif"><br>
Ja pouzivam ADO: <br>
Priklad spracovanie (update) *.dbf suboru:</font><font size="3"> </font><tt><font size="3" color="blue"><br>
<br>
#</font></tt><tt><font size="3"><br>
"""</font></tt><tt><font size="3" color="#ff00ff"><br>
Spracovanie DBF databazy pomocou ADO</font></tt><tt><font size="3"><br>
"""</font></tt><tt><font size="3" color="#8100ff"><br>
import</font></tt><tt><font size="3"> string</font></tt><tt><font size="3" color="blue"><br>
# Pouzitie ADO</font></tt><tt><font size="3" color="#8100ff"><br>
import</font></tt><tt><font size="3"> win32com.client<br>
conn=win32com.client.Dispatch('</font></tt><tt><font size="3" color="#ff00ff">ADODB.Connection</font></tt><tt><font size="3">')</font></tt><tt><font size="3" color="blue"><br>
# Connection String</font></tt><tt><font size="3"><br>
DSN='</font></tt><tt><font size="3" color="#ff00ff">Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\Perl_Python\Database;</font></tt><tt><font size="3" color="#6260a1">\</font></tt><tt><font size="3" color="#ff00ff"><br>
Extended Properties=FoxPro
3.0;</font></tt><tt><font size="3">'</font></tt><tt><font size="3" color="blue"><br>
# print DSN</font></tt><tt><font size="3"><br>
conn.Open(DSN)<br>
rs = win32com.client.Dispatch('</font></tt><tt><font size="3" color="#ff00ff">ADODB.Recordset</font></tt><tt><font size="3">')<br>
rs_name = '</font></tt><tt><font size="3" color="#ff00ff">MyRecordset</font></tt><tt><font size="3">'<br>
rs.CursorLocation = 3<br>
rs.Open("</font></tt><tt><font size="3" color="#ff00ff">SELECT * FROM
rkun000</font></tt><tt><font size="3">", conn,1,3)</font></tt><tt><font size="3" color="blue"><br>
<br>
# Vypis tabulky a update</font></tt><tt><font size="3"><br>
rs.MoveFirst()<br>
count = 0</font></tt><tt><font size="3" color="#813f62"><b><br>
while</b></font></tt><tt><font size="3"> 1: <br>
</font></tt><tt><font size="3" color="#813f62"><b>if</b></font></tt><tt><font size="3"> rs.EOF:<br>
</font></tt><tt><font size="3" color="#813f62"><b>break</b></font></tt><tt><font size="3"> <br>
</font></tt><tt><font size="3" color="#813f62"><b>else</b></font></tt><tt><font size="3">:
<br>
</font></tt><tt><font size="3" color="blue">#
pocet viet</font></tt><tt><font size="3"><br>
count = count + 1<br>
nazov = rs.Fields.Item('</font></tt><tt><font size="3" color="#ff00ff">NAZOV</font></tt><tt><font size="3">').Value<br>
rs.Fields.Item('</font></tt><tt><font size="3" color="#ff00ff">NAZOV</font></tt><tt><font size="3">').Value
= string.capwords(nazov)<br>
</font></tt><tt><font size="3" color="#813f62"><b>print</b></font></tt><tt><font size="3"> rs.Fields.Item('</font></tt><tt><font size="3" color="#ff00ff">NAZOV</font></tt><tt><font size="3">').Value<br>
</font></tt><tt><font size="3" color="blue">#
update aktualnu vetu</font></tt><tt><font size="3"><br>
rs.Update()<br>
</font></tt><tt><font size="3" color="blue">#
next record</font></tt><tt><font size="3"><br>
rs.MoveNext() </font></tt><tt><font size="3" color="#813f62"><b><br>
<br>
print</b></font></tt><tt><font size="3"> "</font></tt><tt><font size="3" color="#ff00ff">Pocet
spracovanych viet v databaze = %d</font></tt><tt><font size="3">" %
count</font></tt><tt><font size="3" color="blue"><br>
<br>
# Ukoncit spojenie</font></tt><tt><font size="3"><br>
conn.Close()</font></tt><font size="3"> <br>
</font><font size="2" face="sans-serif"><br>
<br>
Na Accsess musis zmenit iba connection string - pohladaj si ho (mozno tu):</font><font size="3">
</font><font size="3" color="blue"><u><br>
</u></font><a href="http://www.connectionstrings.com/" target="_blank"><font size="2" color="blue" face="sans-serif"><u>http://www.connectionstrings.com/</u></font></a><font size="3">
</font><font size="3" color="blue"><u><br>
</u></font><a href="http://www.carlprothman.net/Default.aspx?tabid=81" target="_blank"><font size="2" color="blue" face="sans-serif"><u>http://www.carlprothman.net/Default.aspx?tabid=81</u></font></a><font size="3">
<br>
<br>
<br>
</font>
<table width="100%">
<tbody><tr valign="top">
<td width="18%"><font size="1" color="#5f5f5f" face="sans-serif">From:</font><font size="3">
</font>
</td><td width="81%"><font size="1" face="sans-serif">Ondrej Beranek <</font><a href="mailto:rainbof@gmail.com" target="_blank"><font size="1" color="blue" face="sans-serif"><u>rainbof@gmail.com</u></font></a><font size="1" face="sans-serif">></font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">To:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">Konference PyCZ <</font><a href="mailto:python@py.cz" target="_blank"><font size="1" color="blue" face="sans-serif"><u>python@py.cz</u></font></a><font size="1" face="sans-serif">></font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Date:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">04.05.2009 17:46</font><font size="3">
</font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Subject:</font><font size="3">
</font>
</td><td><font size="1" face="sans-serif">[python] access soubor - vytvoření
relací</font><font size="3"> </font>
</td></tr><tr valign="top">
<td><font size="1" color="#5f5f5f" face="sans-serif">Sent by:</font><font size="3">
</font>
</td><td><a href="mailto:python-bounces@py.cz" target="_blank"><font size="1" color="blue" face="sans-serif"><u>python-bounces@py.cz</u></font></a></td></tr></tbody></table>
<br><font size="3"><br>
<br>
</font>
<hr noshade><font size="3"><br>
<br>
<br>
Ahoj, <br>
<br>
potřeboval bych nějak z python skriptu stvořit access databázi (mdb
soubor) a aby toho nebylo dost potřeboval bych v ní ještě vytvořit
relace. Je soubor datové výměny která probíhá denně. Ty relace stačí
vyrobit až po vytvořeníé tabulek.<br>
Přítomnost accessu neni problem. <br>
<br>
Díky za všechny typy.</font><tt><font size="2">_______________________________________________</font></tt><font size="3">
</font><tt><font size="2"><br>
<br>
Python mailing list</font></tt><font size="3" color="blue"><u><br>
</u></font><a href="mailto:Python@py.cz" target="_blank"><tt><font size="2" color="blue"><u>Python@py.cz</u></font></tt></a><font size="3">
</font><font size="3" color="blue"><u><br>
</u></font><a href="http://www.py.cz/mailman/listinfo/python" target="_blank"><tt><font size="2" color="blue"><u>http://www.py.cz/mailman/listinfo/python</u></font></tt></a><font size="3">
<br>
<br>
<br>
_______________________________________________<br>
Python mailing list</font><font size="3" color="blue"><u><br>
</u></font><a href="mailto:Python@py.cz" target="_blank"><font size="3" color="blue"><u>Python@py.cz</u></font></a><font size="3" color="blue"><u><br>
</u></font><a href="http://www.py.cz/mailman/listinfo/python" target="_blank"><font size="3" color="blue"><u>http://www.py.cz/mailman/listinfo/python</u></font></a><font size="3">
</font><tt><font size="2"><br>
_______________________________________________<br>
Python mailing list</font></tt><tt><font size="2" color="blue"><u><br>
</u></font></tt><a href="mailto:Python@py.cz" target="_blank"><tt><font size="2" color="blue"><u>Python@py.cz</u></font></tt></a><font size="3" color="blue"><u><br>
</u></font><a href="http://www.py.cz/mailman/listinfo/python" target="_blank"><tt><font size="2" color="blue"><u>http://www.py.cz/mailman/listinfo/python</u></font></tt></a><font size="3">
<br>
</font>
<br><font size="3"><br>
_______________________________________________<br>
Python mailing list</font><font size="3" color="blue"><u><br>
</u></font><a href="mailto:Python@py.cz" target="_blank"><font size="3" color="blue"><u>Python@py.cz</u></font></a><font size="3" color="blue"><u><br>
</u></font><a href="http://www.py.cz/mailman/listinfo/python" target="_blank"><font size="3" color="blue"><u>http://www.py.cz/mailman/listinfo/python</u></font></a>
<br></div></div><tt><font size="2">_______________________________________________<div class="im"><br>
Python mailing list<br>
<a href="mailto:Python@py.cz" target="_blank">Python@py.cz</a><br>
</div></font></tt><div class="im"><a href="http://www.py.cz/mailman/listinfo/python" target="_blank"><tt><font size="2">http://www.py.cz/mailman/listinfo/python</font></tt></a>
<br>
<br></div></form>
<br>_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@py.cz">Python@py.cz</a><br>
<a href="http://www.py.cz/mailman/listinfo/python" target="_blank">http://www.py.cz/mailman/listinfo/python</a><br></blockquote></div><br>