IRC log for #storm on 20071125

00:00.15*** join/#storm wallflower (n=wallflow@ip-205-246-113-216.pool.grokthis.net)
00:02.29*** join/#storm sigtim (n=tim@ws253-244.sig.msstate.edu)
00:03.08sigtimhello.  any idea if storm can handle arrays in PostgreSQL ?
00:03.45radixsigtim: It can
00:04.13sigtimlet's say I have a column number integer[]
00:04.27sigtimhow do I define it in storm class?
00:06.25radixsigtim: I think just as number = List()
00:06.39radix(where List comes from storm.properties)
00:09.14sigtimradix:     blocks = store.find(Block, Block.counties_in_cd[3] == 1)
00:09.14sigtimTypeError: 'PropertyColumn' object is unindexable
00:09.34radixsigtim: counties_in_cd is a postgres array?
00:09.43sigtimyes.  integer[]
00:09.52radixsigtim: I don't really understand what SQL you could possibly want to generate from that expression
00:09.59sigtimtried counties_in_cd = List() and List(Int()) - no luck.
00:10.38sigtimradix: each county can be in multiple congressional districts.
00:10.54sigtimin this case, there are only 4 cd's, so I could separate into variables cd1, cd2, etc. I suppose.
00:11.00sigtimbut I have a case later where membership is in hundreds.
00:11.19radixsigtim: Can you give an example of the SQL you want to generate?
00:11.20sigtimalso would rather not do a join, a few hundred k rows.
00:11.56sigtimsql: select name from blocks where counties_in_cd[3] = 1
00:13.16sigtimthe array tests for membership.  I probably should consider a join, but I need to generate a lot of reports out of this later so would prefer to get all the data into a table.
00:13.29radixsigtim: Ok. I don't think Storm supports comparing individual elements of postgres arrays (I wasn't even previously aware that was possible)
00:13.40radixsigtim: indexes are your friend :)
00:15.53sigtimthanks - let me try that.  I should stay away from such db specific features anyway, but couldn't resist.
00:16.59radixsigtim: wait, what does "counties_in_cd[3] = 1" do exactly? Does it check to see if the third element in the array is equal to 1?
00:17.29radixAre you sure that's possible? I don't see that kind of thing at http://www.postgresql.org/docs/8.2/static/functions-array.html
00:18.42sigtimsee here.http://www.postgresql.org/docs/8.0/interactive/arrays.html
00:18.55sigtimbut yeah, that's what it does.  sql: select count(*) from sig_map where county_in_cd[3] = 1
00:18.57sigtimresult: 45808
00:19.20radixah, ok
00:19.30radixI guess then it would be good for storm to support that
00:19.56sigtimyou might also want to look into inheritance as well.  I try to stay away from it but one of the nicer things about postgresql.
00:20.16radixwhat do you mean?
00:20.24radixI don't think storm needs any special support for Postgres inheritance
00:20.25sigtimyou can inhert from another table.
00:20.51radixI know about postgres inheritance
00:21.01radix(as an aside, I've found postgres inheritance to be mostly useless)
00:22.25sigtimI don't have an informed opinion on that but I will take your word for it.  I am learning python & storm to get away from Perl/DBI.  The main attraction is the clean syntax/design for me so a lot of this is new.  I've never used inheritance in postgres though so just thought I point out.
00:24.27radixcool :)
00:24.32radixI only recently looked at the inheritance stuff, actually
00:25.23radixit seems that it gives you the ability to treat subclasses and superclasses as homogenous things in only uninteresting ways
00:28.36*** join/#storm Key_Gena (i=lok@gateway/tor/x-9be7b17777765114)
00:29.39sigtimRadix: I think you'll lose me in a hurry - I am behind in OO concepts ("old" embedded systems programmer who's now getting into web applications).  I did just tried a join and it worked beautifully.  Cool - I find that the older I get the lazier I am and storm/python really map into the way I think a lot better.  It's almost declarative and to me that's the beauty of it.
00:30.14radixhehe
00:35.00sigtimradix:  thanks again.  I know I am a newbie web framework wise but I've played with just about every ORM in every language and I think storm and django are by far the best ones.  Most of the others I can't even get past the syntax (and that says a lot from a guy who writes a lot of Perl - heh).  Can't wait to see storm evolve but I think I've got enough to finish these reports I need to do.  Thanks!
00:37.55radixsigtim: sweet! good luck with your project.
01:13.04radixAnyone know of a decent way to represent (and query for) objects in symmetric relationships in SQL?
02:14.43jkakarradix: What do you mean by 'symmetric relationships'?
02:17.32radixhttp://en.wikipedia.org/wiki/Symmetric_relation :-)
02:18.02radix"# symmetric: for all x and y in X it holds that if xRy then yRx. "Is a blood relative of" is a symmetric relation, because x is a blood relative of y if and only if y is a blood relative of x."
02:19.18radixso if you have a blood_relation table with columns "person1" and "person2", and you want to query for all blood relations of a person, you have a couple options AFAICT
02:20.24radixyou can either copy each row to its inverse, so that you can always query on the same column,
02:21.08radixor you can do a query like "SELECT * from blood_relation WHERE person1 = X OR person2 = X;", and then go through the result checking to see which side X came out on, and using the opposite side
02:22.05radixmaybe there are more clever things
02:22.53radixhmm, I guess you could split it out further to a "blood_relation" table with columns relation_id, participant
02:23.30radixand do something like SELECT participant FROM blood_relation WHERE relation_id = (SELECT relation_id FROM blood_relation WHERE participant = X)
02:24.45radix(is there a better query than that, given that schema?)
02:25.51radixinsertions into that schema could be a minor pain, since you can't just use a SEQUENCE column for relation_id, you have to insert with the same unique ID in pairs
02:26.09radixbut UUID should be fine for that
02:27.48radixscratch that last line, brainfart
02:32.02jkakarHuh, neat.
03:23.59radixhttp://radix.twistedmatrix.com/2007/11/representing-symmetric-relations-in.html
03:24.26radixI wrote a blog post about this to hopefully get some feedback.
03:33.26*** join/#storm Key_Gena (i=lok@gateway/tor/x-e7f72f1c2321a883)
03:38.41sigtimradix: this is a more "computer science" approach.  http://www.dbmsmag.com/9704d06.html
03:39.13sigtimI am hardly a db person, but I'd try something like create table r (person1, person2, direction)
03:39.32sigtimdirection can be one way or two way.
03:40.09sigtimyou have to do more work with queries and insertions, but I think you can avoid any explicit transactions.
03:43.53radixyeah, I've read that page several times. It takes the approach of duplicating the data.
03:44.06radixI'm not sure what you mean by "explicit transactions"
03:44.44radixand given that I'm only talking about two-way (symmetric) relationships, I'm not sure how your schema is beneficial
03:45.41sigtimthe dbms approach wraps two statements around a transaction.
03:46.21sigtimhmm, I am confused.  if your database only contains two-way relationships, then by definition all rows have the symmetric relationship.
03:47.32radixMaybe I don't understand what you mean by "two-way relationship". I assumed it meant the same thing as "symmetric relationship".
03:47.37sigtimI am assuming that your rows contains one way relationships, and you want to find the symmetrical relations out of them.
03:47.55sigtimin your table design, (a,b) only implies a->b, but not b->a
03:48.08sigtimso you are trying to find all cases where a->b and also b->a, two rows.
03:48.12sigtimin first schema anyway.
03:48.18radixsigtim: In a table (a, b), it's possible to treat the relationship as symmetric, if you just write your code and queries in the right way
03:48.22radixsigtim: which I described in the blog post
03:48.29radix"
03:48.29radix"This is the most trivial and straightforward in-database representation of a symmetric relationship between two participants. Actually, this schema could represent an asymmetric relationship as well, but we'll write our queries and application code so that (participant1=X, participant2=Y) is treated the same as (participant1=Y, participant2=X).
03:48.35radix"
03:49.09radixThe two options with schema 1 are to EITHER store symmetric relationships as two rows, OR perform a fancy query which allows you to only have one row.
03:49.18sigtimah I gotcha.
03:49.30radixboth of those options are pretty sucky
03:49.45radixthe first for the fact that you have to maintain two rows explicitly, the second because the querying and processing is really awkward
04:09.54sigtimpersonally, I don't feel schema 1 is so bad either way, depends on what you are optimizing for.  the only db I know that has problem with multi-column indexes is sqlite - can't imagine mysql, postgresql, having problems with that.  but I'll have to defer to those far more knowledgeable on databases than I on this.  interesting problem.  gotta run - catch you later!
04:10.12*** part/#storm sigtim (n=tim@ws253-244.sig.msstate.edu)
05:10.59*** join/#storm sigtim (n=Tim@64.234.56.136)
05:11.28sigtim/users
05:12.11*** part/#storm sigtim (n=Tim@64.234.56.136)
05:12.52*** join/#storm sigtim (n=Tim@64.234.56.136)
07:22.52*** join/#storm goschtl (n=goschtl@pD9E5DC95.dip.t-dialin.net)
07:59.37*** join/#storm goschtl_ (n=goschtl@pD9E5DC95.dip.t-dialin.net)
09:13.13*** join/#storm jukart (n=jukart@85-124-221-45.static.xdsl-line.inode.at)
09:20.44*** join/#storm Key_Gena (i=lok@gateway/tor/x-54b85bc30ea5e8e8)
10:45.28*** join/#storm goschtl (n=goschtl@pD9E5DC95.dip.t-dialin.net)
12:10.20*** join/#storm jukart (n=jukart@85-124-221-45.static.xdsl-line.inode.at)
14:35.10*** join/#storm Zenom (n=aj1973@unaffiliated/aj1973)
15:32.43*** join/#storm jukart (n=jukart@85-124-221-45.static.xdsl-line.inode.at)
17:15.29*** join/#storm niemeyer (n=niemeyer@201-10-91-193.ctame705.dsl.brasiltelecom.net.br)
17:34.55*** join/#storm WebMaven_ (n=webmaven@ip72-193-218-163.lv.lv.cox.net)
17:57.56*** join/#storm goschtl (n=goschtl@pD9E5EE2E.dip.t-dialin.net)
18:15.10*** join/#storm goschtl_ (n=goschtl@pD9E5EE2E.dip.t-dialin.net)
18:15.41*** join/#storm bigdog (n=scmikes@72-197-8-8-arpa.cust.cinci.current.net)
18:38.32*** join/#storm goschtl (n=goschtl@pD9E5EE2E.dip.t-dialin.net)
18:51.48*** join/#storm goschtl (n=goschtl@pD9E5EE2E.dip.t-dialin.net)
18:57.41*** join/#storm goschtl (n=goschtl@pD9E5EE2E.dip.t-dialin.net)
19:04.49goschtlniemeyer: i have created a new version for the storm zope container. I will post the changes to the maillinglist tomorrow. And i try to host the code on googlecode. But i think i need some help on two points.
19:06.18niemeyergoschtl: Hey
19:06.22niemeyergoschtl: Sure, what's up?
19:07.07goschtlIs it possible to get an kind of an *instance_key(obj)* for storm.
19:07.24goschtlin sqlalchemy there is a function like this
19:08.03niemeyergoschtl: What does it do?
19:08.43goschtlyou can look on the instance functions here http://svn.sqlalchemy.org/sqlalchemy/trunk/lib/sqlalchemy/orm/mapper.py --> primary_key_from_instance ...
19:11.44goschtli need this for a kind of traversal in zope. now i interate through the primary_vars in obj_info look here http://paste.plone.org/18125
19:12.16niemeyergoschtl: This should do it:
19:12.19niemeyerdef instance_key(obj):
19:12.19niemeyer<PROTECTED>
19:12.19niemeyer<PROTECTED>
19:12.19niemeyer<PROTECTED>
19:13.08*** join/#storm bigdog (n=scmikes@72-197-8-8-arpa.cust.cinci.current.net)
19:13.13goschtlniemeyer: thx i will try
19:21.46*** join/#storm bigdo1 (n=scmikes@72-197-8-8-arpa.cust.cinci.current.net)
20:40.19*** join/#storm dobee (n=dobeee@81-223-53-162.dornbirn.xdsl-line.inode.at)
20:42.35*** join/#storm dobee (n=dobeee@81-223-53-162.dornbirn.xdsl-line.inode.at)
20:52.54*** part/#storm sigtim (n=Tim@64.234.56.136)
21:13.27*** join/#storm bigdog (n=scmikes@72-197-8-8-arpa.cust.cinci.current.net)
21:14.53*** join/#storm bozzo (n=bozzo@BSN-77-50-2.dial-up.dsl.siol.net)
22:42.29*** join/#storm jml (n=jml@li2-200.members.linode.com)
22:55.22*** join/#storm dotz (n=dotz@chello089078004026.chello.pl)
23:02.54*** join/#storm Zenom (n=Zenom@unaffiliated/aj1973)
23:28.52*** join/#storm dotz (n=dotz@chello089078004026.chello.pl)

Generated by irclog2html.pl Modified by Tim Riker to work with infobot.