thanks. <br><br><div><span class="gmail_quote">On 12/03/2008, <b class="gmail_sendername">James Henstridge</b> <<a href="mailto:james@jamesh.id.au">james@jamesh.id.au</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On 12/03/2008, mark. a. brand <<a href="mailto:mark.a.brand@gmail.com">mark.a.brand@gmail.com</a>> wrote:<br> > hi:<br> ><br> > *** newbie-alert ***: both python and storm<br> ><br> > the bit of code below - apparently works in sqlalchemy with sqlalchemy<br>
> syntax of course.<br> ><br> > my question is how can i do the same thing in storm, ie create a whole bunch<br> > or instances at once via a dict.<br> ><br> > database = create_database("sqlite:hc.db")<br>
> store = Store(database)<br> ><br> > class Process(Storm):<br> > __storm_table__ = "process"<br> > ProcessId = Int(primary = True)<br> > Caption = Unicode()<br> ><br> > store.execute("CREATE TABLE process " "( \<br>
> ProcessId VARCHAR, \<br> > Caption VARCHAR)",<br> > noresult = True \<br> > )<br> ><br> > c = wmi.WMI ()<br> > for process in c.Win32_Process (['ProcessId', 'Caption']):<br>
> d = dict ((p, getattr (process, p)) for p in process.properties)<br> > Process (**d)<br> <br> <br>You need to add these process objects to the store:<br> store.add(Process(**d))<br> <br> <br> > storm.flush()<br>
> storm.commit()<br> <br> And this should be store.commit() rather than storm.commit(). You<br> should not need the flush() call.<br> <br><br> James.<br> </blockquote></div><br>