@# Quotes DB     useful, funny, interesting





Google
 
Web www.quotesdb.info
Undernet  |  EFnet  |  Quakenet  |  Freenode  |  Dalnet  |  Ircnet  |  Galaxynet
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32



Comments:

<0> Peyomp: You want to learn how to do a join. Now. It's not too hard.
<0> revdiablo: Well, could be a bad view....
<1> A JOIN isn't gonna help me here.
<0> Well, 308 queries to get 308 records is not the right way.
<1> Its not to get 208 records
<0> 22:37 < Somni> why are you making 308 queries?
<0> 22:37 < Peyomp> There's 308 IDs Im interested in
<1> It could be (24*31) for each of 308 values
<2> Masque: Have you ever heard of an IN clause?
<0> haha
<0> Gosh, no! Do tell.
<2> :P
<0> Also, what's this "WHERE" thing?
<2> You gotta see where we're coming from here
<2> Either you're leaving out important information, or you're retarded.



<2> Possibly both
<1> I think its both. My gf called me. Just a sec.
<0> Earlier he was asking how to do something that a join would solve.
<0> This is why I ***umed.
<1> I didn't adequately describe it.
<0> See, he has a girlfriend - perhaps it's just that he has priorities.
<1> But your advice was helpful.
<0> And he properly punctuates and capitalizes, for the most part. I think there's hope.
<2> oops, I needed s/Masque/Peyomp/ a minute ago
<3> how's it going?
<0> revdiablo: Oh, that does make more sense then.
<2> skiddieleet: Fantastically
<4> DCC SEND AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
<1> Okay, so in my application you specify a start date and time and end date and time you want to report on. In the database, there are hourly entries for 308 machines. I need to grab all that data for the period between start date and time and end date and time for all 308 machines. Then I need to perform calculations on this data in such a way that it is neccessary that I for instance, sum...
<1> ...all of certain values for a particular machine.
<1> I was trying to grab it all at once, and then sort it so that I have an array of entries for each machine in a hash
<1> and the machine ID is the key to that hash
<2> That sounds perfectly sensible to do in one query
<1> Actually an array of arrays in a hash entry
<1> Right, but I got stumped in rearranging the data from the array of arrays I got from the SQL query.
<1> I haven't done that much programming in a while. My algorithmic skills are bankrupt.
<1> One way to avoid rearranging the data is to do 308 separate queries. Thats probably not the best way, though?
<2> No, probably not.
<2> I don't understand what you mean by "rearrange the data", though. What exactly was the problem?
<5> revdiablo: Peyomp can't seem to define it :)
<3> where's zshzn?
<5> which probably makes writing a query very difficult
<1> So, I have this array of arrays that holds the query, and I need to create a hash for each machine ID, which is one of the values from the query, and ***ign the rows that have that machine ID to an array referred to by a hash where the machine ID is the key.l
<0> Peyomp: Describe, in english, the result you want.
<0> "I want to find the frobble for each whizbang under fruit loop city."
<5> that just sounds like a selectall_hashref!
<1> I want to arrange the data so that it sits in a hash where the machine ID is the key.
<1> and all entries with the machine ID in them are referred to from that hash entry
<1> Jesus, with THAT machine ID in them
<0> That's almost what I wanted.
<6> really? so your end result is a hash, that you're just going to.. print?
<0> You're still a couple of layers deep.
<1> No, once I get the hash going I have all kinds of statistics to compute, but those details aren't neccessarily relevant.
<1> I can handle their computation, I don't need help with that.
<2> As a side note, you could probably do everything in SQL directly
<6> the database might easily help with that
<1> So I should do this in SQL instead of doing a simple SELECT * and then processing the results?
<6> it depends on the data, and the result
<6> but yes, you should generally do as much work as close to the data as you can
<1> Since I am capable of doing the calculations in perl, but not in SQL, because I lack the expertise to do so, I thought to do it this way. However, I am unable to perform this array->hash operation I just described.
<1> And it is neccessary that I do so in order to proceed this way.
<1> Its possible that I've done too much today and should sleep on it. But deadlines loom. So I thought... IRC :)
<2> You can get results as a hash from DBI
<5> which each key is the machine id ;)
<5> s/which/where/
<2> As Khisanth said, selectall_hashref
<5> and the values can either be arrayrefs or hashrefs
<0> ;)
<2> Peyomp: Basically, you need to spend more time learning what tools are available and less time trying to do it all yourself
<0> Peyomp: But don't feel bad - smart people tend to do things like this. I'm guilty of it regularly.
<1> But... since I need to create a hash where ALL entries that contain a particular machine ID are stored with that machine ID as the key, I'm not sure that doing a selectall_hashref helps, does it?
<1> Right, I agree. Thing is, we're creating a demo on a short timeline, selling it, and then doing it right.
<6> haha, yea, right
<1> Like I want an array where you have a $hashref{308} and that contains an array that holds say... 600 arrays.



<1> Yes, I've worked at places that SAID they would do that, but didn't.
<1> But thats sorta off topic.
<6> "Yea, let's just create this demo fast and stupid. We'll fix it later."
<1> "You always throw one away."
<6> "Ok, demo's over. Hey, the code works, doesn't it? Let's just use it."
<1> Whether you do it now, or later.
<1> I have read the mythical man month, and I can ***ure you that this ****er will be redone.
<1> I have spent years working on bankrupt demo code.
<0> I like you, Peyomp. How old are you?
<1> 26. Thanks, I try to be likable.
<1> or is it likeable?
<6> lickable
<0> Mmm. Yeah, you struck me as the 25-30 type.
<0> It's likable.
<1> Look, I have a $3000 tradeshow booth.
<1> I have to show something.
<1> Its that simple.
<1> Know what i mean?
<5> heh
<0> So. Know that sql can do what you want.
<0> Know that DBI can do what you want.
<0> selectall_hashref does what you want.
<7> I am working on my bot, and it takes something like !resolve <host>....and I am parsing with $text =~ /^!resolve (.+)/i how do I make it so that it doesn't matter if the argument is there and then test?
<8> Is it possible to clean every build directory with CPAN.pm?
<7> So it can print a help or something.
<9> Peyomp: Show them UML diagrams!
<0> MacVince: It's possible with rm, if nothing else.
<1> haha
<2> Err, selectall_hashref says it expects the keys to be unique per row
<5> Masque: but that is getting ahead, first he has to know what he has and what he wants or at least be able to describe both
<2> So I don't think it will work, actually.
<10> g0st: if( $text =~ s/^!resolve\s+// ) { ... } is one way
<7> Would I do something like /^!resolve (.+)?/i
<8> Masque: is there any "danger" in rm'ing those?
<1> I think that I have described both. What I have left out is the business logic, but you don't need that.
<0> Khisanth: Yes, but he'll feel better knowing he's on the right track.
<10> Or perhaps \s*.
<0> MacVince: rm is always dangerous. But basically, no.
<9> "And over here, the blue boxes, that's the accounting system. See the little man? That's you. See the giant cannon? That's ..."
<7> b0at: what about /^!resolve (.+)?/i work?
<10> That requires a space.
<7> I want it to be true whether or not the arg is there.
<7> And then just if($1) {} else {}
<5> Peyomp: so far I have only seen you describe what YOU THINK is the solution
<1> Its one way of doing it.
<10> g0st: If you do it my way, you just look at $text for the rest of the stuff.
<0> Peyomp: Have you read the docs for DBI's fetchall_hashref?
<0> Khisanth: We've established long ago that we have an xy problem here. The thing is that Peyomp is open to that possibility.
<1> Maybe I should read that now.
<0> So perhaps it's not useful to keep screaming "OMG XY PROBLEM"
<10> Or /^!resolve\s*(\S+|)/ maybe
<6> //^!resolve(\s+(.+))?/
<6> /^!resolve(\s+(.+))?/
<6> /^!resolve(\s+(.+))?$/ would be better
<1> Son of a bitch...
<1> You are right!
<1> :)
<1> Thanks
<0> My mother is quite a nice lady.
<1> I mean that in the non-offensive, "Great Scott!" sense.
<0> But you're welcome. :)
<0> Yeah, I know. :)
<1> fetchall_hashref is my friend. Serves me right for not completely reading the DBI docvs.
<1> s/docvs/docs/
<0> It does. But there you go.
<1> Thanks mucho.
<0> btw, don't avoid #perl. It's a good place to hang out.
<0> But help questions are better asked here until you're a regular there.
<1> http://lucision.com/legal/rjurney/Booth.jpg
<1> Thats the tradeshow booth


Name:

Comments:

Please enter the result of the sum 63 + 46 (to avoid spam):






Return to #perl
or
Go to some related logs:

suse-10 change-mac-address
emerge-delta-webrsync eix-sync
#iptables
qt4 sles9
#suse
kdirlist
#sdl
#debian
silverpower irc
Unable to add forward map from : bad DNS key



Home  |  disclaimer  |  contact  |  submit quotes