Uz to odkoukavam tady:<br><br><a href="http://msdn.microsoft.com/en-us/library/bb243835.aspx">http://msdn.microsoft.com/en-us/library/bb243835.aspx</a><br><br>pokusim se to tam naprat jako sadu SQL prikazu.<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">Jake relacie myslis? </font>
<br><font size="2" face="sans-serif">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>
<br>
<br>
<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:03</font>
</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><div><div></div><div class="h5">
</div></div></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">Přes ADO to vypadá jednoduše. Nenašel jsem ale způsob
jak to donutit tvořit relace mezi tabulkami.<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">Ja pouzivam ADO: <br>
Priklad spracovanie (update) *.dbf suboru:</font><font size="3"> <br>
</font><tt><font size="3" color="blue"><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>
<br>
</font><font size="2" face="sans-serif"><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>
<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>
</font>
<hr noshade><font size="3"><br>
<br>
</font>
<br><font size="3">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>
</font>
<br><font size="3">Díky za všechny typy.</font><tt><font size="2">_______________________________________________</font></tt>
<br><tt><font size="2"><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>
<br><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><tt><font size="2">_______________________________________________<br>
Python mailing list<br>
<a href="mailto:Python@py.cz" target="_blank">Python@py.cz</a><br>
</font></tt><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></div><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>