<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&amp;q=data+relation+ADO&amp;meta=&amp;aq=f&amp;oq="><font size=2 face="sans-serif">http://www.google.sk/search?hl=sk&amp;q=data+relation+ADO&amp;meta=&amp;aq=f&amp;oq=</font></a>
<br><font size=2 face="sans-serif">tak mi to vyhodilo same linky suvisiace
s ADO.NET - napriklad tu </font>
<br>
<br><a href="http://www.c-sharpcorner.com/UploadFile/cvinodkumar/DataRelationVK11292005072318AM/DataRelationVK.aspx"><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 ADO.NET.</font>
<br>
<br><font size=2 face="sans-serif">ADO.NET 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><font size=2 face="Verdana">DataSet.Relations.Add()
)</font>
<br>
<br><font size=2 face="sans-serif">ADO.NET som skusal s IronPythonom (
</font><a href=http://www.codeplex.com/IronPython><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 VB.NET</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>&quot;&quot;&quot;</font></tt><tt><font size=3 color=#ff00ff><br>
Pouzitie ADO.NET pre pristup do AS/400<br>
s vyuzitim DataSet a DataAdapter</font></tt><tt><font size=3><br>
&quot;&quot;&quot;<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&nbsp;&nbsp; ='</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 ADO.NET</font></tt><tt><font size=3 color=#8100ff><br>
import</font></tt><tt><font size=3>&nbsp;clr</font></tt><tt><font size=3 color=#8100ff><br>
import</font></tt><tt><font size=3>&nbsp;System<br>
clr.AddReference(&quot;</font></tt><tt><font size=3 color=#ff00ff>System.Data</font></tt><tt><font size=3>&quot;)</font></tt><tt><font size=3 color=#8100ff><br>
import</font></tt><tt><font size=3>&nbsp;System.Data<br>
</font></tt><tt><font size=3 color=#8100ff><br>
from</font></tt><tt><font size=3>&nbsp;System.Data.OleDb </font></tt><tt><font size=3 color=#8100ff>import</font></tt><tt><font size=3>&nbsp;OleDbConnection
</font></tt><tt><font size=3 color=#8100ff>as</font></tt><tt><font size=3>&nbsp;dbconnection</font></tt><tt><font size=3 color=#8100ff><br>
from</font></tt><tt><font size=3>&nbsp;System.Data.OleDb </font></tt><tt><font size=3 color=#8100ff>import</font></tt><tt><font size=3>&nbsp;OleDbDataAdapter
</font></tt><tt><font size=3 color=#8100ff>as</font></tt><tt><font size=3>&nbsp;dbdataadapter</font></tt><tt><font size=3 color=#8100ff><br>
from</font></tt><tt><font size=3>&nbsp;System.Data </font></tt><tt><font size=3 color=#8100ff>import</font></tt><tt><font size=3>&nbsp;DataSet
</font></tt><tt><font size=3 color=#8100ff>as</font></tt><tt><font size=3>&nbsp;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 = &quot;</font></tt><tt><font size=3 color=#ff00ff>SELECT
* FROM r000100T.r000270V</font></tt><tt><font size=3>&quot;</font></tt><tt><font size=3 color=blue><br>
#sqlStatement = &quot;SELECT * FROM r000100T.p400100v&quot;<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(&quot;MyDataSet&quot;)</font></tt><tt><font size=3><br>
ds=dataset(&quot;</font></tt><tt><font size=3 color=#ff00ff>MyDataSet</font></tt><tt><font size=3>&quot;)<br>
</font></tt><tt><font size=3 color=blue><br>
# Naplnit Dataset</font></tt><tt><font size=3><br>
da.Fill(ds, &quot;</font></tt><tt><font size=3 color=#ff00ff>MyTable</font></tt><tt><font size=3>&quot;)<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>&nbsp;table </font></tt><tt><font size=3 color=#813f62><b>in</b></font></tt><tt><font size=3>&nbsp;ds.Tables:<br>
&nbsp;&nbsp;</font></tt><tt><font size=3 color=#813f62><b>print</b></font></tt><tt><font size=3>&nbsp;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>&nbsp;row </font></tt><tt><font size=3 color=#813f62><b>in</b></font></tt><tt><font size=3>&nbsp;ds.Tables[0].Rows:<br>
&nbsp;&nbsp;count +=1<br>
&nbsp;&nbsp;</font></tt><tt><font size=3 color=#813f62><b>print</b></font></tt><tt><font size=3>&nbsp;&quot;</font></tt><tt><font size=3 color=#ff00ff>%10s
%10s %10s %10s</font></tt><tt><font size=3>&quot;&nbsp;% (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>&nbsp;&quot;</font></tt><tt><font size=3 color=#ff00ff>pocet
viet v tabulke je: %d</font></tt><tt><font size=3>&quot;&nbsp;% 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%>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">From:</font>
<td><font size=1 face="sans-serif">Ondrej Beranek &lt;rainbof@gmail.com&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font>
<td><font size=1 face="sans-serif">Konference PyCZ &lt;python@py.cz&gt;</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font>
<td><font size=1 face="sans-serif">05.05.2009 17:58</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font>
<td><font size=1 face="sans-serif">Re: [python] access soubor - vytvoření
relací</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Sent by:</font>
<td><font size=1 face="sans-serif">python-bounces@py.cz</font></table>
<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"><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 &lt;</font><a href=mailto:RMiklos@pss.sk><font size=3 color=blue><u>RMiklos@pss.sk</u></font></a><font size=3>&gt;</font>
<br><font size=2 face="sans-serif">Jake relacie myslis? &nbsp;</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%>
<tr valign=top>
<td width=17%><font size=1 color=#5f5f5f face="sans-serif">From:</font><font size=3>
</font>
<td width=82%><font size=1 face="sans-serif">Ondrej Beranek &lt;</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">&gt;</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">Konference PyCZ &lt;</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">&gt;</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">05.05.2009 17:03</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">Re: [python] access soubor - vytvoření
relací</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Sent by:</font><font size=3>
</font>
<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></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 &lt;</font><a href=mailto:RMiklos@pss.sk target=_blank><font size=3 color=blue><u>RMiklos@pss.sk</u></font></a><font size=3>&gt;
</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>
&quot;&quot;&quot;</font></tt><tt><font size=3 color=#ff00ff><br>
Spracovanie DBF databazy pomocou ADO</font></tt><tt><font size=3><br>
&quot;&quot;&quot;</font></tt><tt><font size=3 color=#8100ff><br>
import</font></tt><tt><font size=3>&nbsp;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>&nbsp;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>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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(&quot;</font></tt><tt><font size=3 color=#ff00ff>SELECT * FROM
rkun000</font></tt><tt><font size=3>&quot;, 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>&nbsp;1: <br>
&nbsp;&nbsp; </font></tt><tt><font size=3 color=#813f62><b>if</b></font></tt><tt><font size=3>&nbsp;rs.EOF:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt><tt><font size=3 color=#813f62><b>break</b></font></tt><tt><font size=3>&nbsp;<br>
&nbsp;&nbsp; </font></tt><tt><font size=3 color=#813f62><b>else</b></font></tt><tt><font size=3>:
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt><tt><font size=3 color=blue>#
pocet viet</font></tt><tt><font size=3><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;count = count + 1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nazov&nbsp;&nbsp;= rs.Fields.Item('</font></tt><tt><font size=3 color=#ff00ff>NAZOV</font></tt><tt><font size=3>').Value<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.Fields.Item('</font></tt><tt><font size=3 color=#ff00ff>NAZOV</font></tt><tt><font size=3>').Value
= string.capwords(nazov)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt><tt><font size=3 color=#813f62><b>print</b></font></tt><tt><font size=3>&nbsp;rs.Fields.Item('</font></tt><tt><font size=3 color=#ff00ff>NAZOV</font></tt><tt><font size=3>').Value<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt><tt><font size=3 color=blue>#
update aktualnu vetu</font></tt><tt><font size=3><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.Update()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font></tt><tt><font size=3 color=blue>#
next record</font></tt><tt><font size=3><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.MoveNext() </font></tt><tt><font size=3 color=#813f62><b><br>
<br>
print</b></font></tt><tt><font size=3>&nbsp;&quot;</font></tt><tt><font size=3 color=#ff00ff>Pocet
spracovanych viet v databaze = %d</font></tt><tt><font size=3>&quot;&nbsp;%
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%>
<tr valign=top>
<td width=18%><font size=1 color=#5f5f5f face="sans-serif">From:</font><font size=3>
</font>
<td width=81%><font size=1 face="sans-serif">Ondrej Beranek &lt;</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">&gt;</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">To:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">Konference PyCZ &lt;</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">&gt;</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Date:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">04.05.2009 17:46</font><font size=3>
</font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Subject:</font><font size=3>
</font>
<td><font size=1 face="sans-serif">[python] access soubor - vytvoření
relací</font><font size=3> </font>
<tr valign=top>
<td><font size=1 color=#5f5f5f face="sans-serif">Sent by:</font><font size=3>
</font>
<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></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><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><tt><font size=2>_______________________________________________<br>
Python mailing list<br>
Python@py.cz<br>
</font></tt><a href=http://www.py.cz/mailman/listinfo/python><tt><font size=2>http://www.py.cz/mailman/listinfo/python</font></tt></a>
<br>
<br></form>