Why do people still ask for CSV dumps of raw data they don't need?


  • Garbage Person

    A complete Python script to dump a bunch of data out of a database into a semicolon-separated textfile because some backasswards loser refuses to tell the development team for a new system WTF they need to do with it so we can build a feature into the system to do it without wasting human time on manipulating a tens-of-thousands-of-lines excel file. There's a lot of uncertainty from a lot of people within this client because they can't see the data, so I get the feeling this is just a security blanket thing.

    Python is usually the LAST language you find WTFy crap in - but here it is, in the flesh.If it were in source control instead of just sitting in a directory on a totally unrelated unix box, owned by root (wtf?), I could go teach somebody about recursion.

    #!/usr/bin/python

    import pymssql
    conn = pymssql.connect(host='db', user='user', password='testsystem', database='client')
    cur = conn.cursor()
    cur.execute('exec sp_getTopLevelCategories -1')
    conn2 = pymssql.connect(host='db', user='user', password='testsystem', database='client')
    cur2 = conn2.cursor()
    for lev1 in cur.fetchall():
    print '%d;%s;%s;' % (lev1[0], lev1[1], lev1[2])
    cur.execute('exec sp_getChildCategories %d, -1' % (lev1[0]))
    for lev2 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev2[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s;' % (lev2[0], lev2[1], lev2[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev2[0]))
    for lev3 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev3[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s;' % (lev3[0], lev3[1], lev3[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev3[0]))
    for lev4 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev4[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s;' % (lev4[0], lev4[1], lev4[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev4[0]))
    for lev5 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev5[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s' % (lev5[0], lev5[1], lev5[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev5[0]))
    for lev6 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev6[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'

    print '%d;%s;%s;%s;' % (lev6[0], lev6[1], lev6[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev6[0]))
    for lev7 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev7[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s' % (lev7[0], lev7[1], lev7[2], prizes)
    cur.execute('exec sp_getChildCategories %d, -1' % (lev7[0]))
    for lev8 in cur.fetchall():
    cur2.execute('select dollarValue from tbl_Prizes WHERE contestID = %s ORDER BY place' % (lev8[0]))
    prizes = ''
    for prize in cur2.fetchall():
    prizes += str(prize[0])+';'
    print '%d;%s;%s;%s' % (lev8[0], lev8[1], lev8[2], prizes)


    conn.close()
    conn2.close()


  • You better be glad he did it in python - I doubt he'ld have indented the copypasted code if he didn't have to.

    Er, why, exactly, are there two database connections? Now I don't know much about stored procedures, except that they exist. Do they need to be executed in a seperate connection?



  • @derula said:

    You better be glad he did it in python - I doubt he'ld have indented the copypasted code if he didn't have to.
    Plus it means there aren't a bunch of closing braces in a row at the end.



  • @bstorer said:

    Plus it means there aren't a bunch of closing braces in a row at the end.

     

    What is wrong with closing brackets (they come naturaly on the end of the line (they have never hurt you in any way (only made you blind (but real hackers dont need eyes (they dont need screens (or computers))))))?



  • @Weng said:

    A complete Python script to dump a bunch of data out of a database into a semicolon-separated textfile because some backasswards loser refuses to tell the development team for a new system WTF they need to do with it so we can build a feature into the system to do it without wasting human time on manipulating a tens-of-thousands-of-lines excel file. There's a lot of uncertainty from a lot of people within this client because they can't see the data, so I get the feeling this is just a security blanket thing.

     

    If they don't get to see the data, except in small, pre-processed chunks you pass them, I can understand them, even IF it's just a psychological thing. I've no idea what you'd want to do with that data, but maybe some people have no real idea yet, either, but will be able to clarify their thoughts if they get to look at the raw table. So maybe a simple (read-only) DB viewer would have been the better solution?

     

    @Gnonthgol said:

    What is wrong with closing brackets (
      they come naturaly on the end of the line (they have never hurt you in any way (
        only made you blind (
          but real hackers dont need eyes (
            they dont need screens (
              or computers
            )
          )
        )
      )
    )?

    FTFY. Learn 2 indent, n00b!

     



  • @PSWorx said:

    @Gnonthgol said:

    What is wrong with closing brackets (
      they come naturaly on the end of the line (they have never hurt you in any way (
        only made you blind (
          but real hackers dont need eyes (
            they dont need screens (
              or computers
            )
          )
        )
      )
    )?

    FTFY. Learn 2 indent, n00b!

     

    That is just poetry.

    I mean, real bad poetry, but still.



  • @PSWorx said:

    @Gnonthgol said:
    What is wrong with closing brackets (
    they come naturaly on the end of the line (
    they have never hurt you in any way (
    only made you blind (
    but real hackers dont need eyes (
    they dont need screens (
    or computers
    )
    )
    )
    )
    )
    )?

    FTFTFYFY


  • Garbage Person

    @derula said:

    Er, why, exactly, are there two database connections? Now I don't know much about stored procedures, except that they exist. Do they need to be executed in a seperate connection?
    I'm not an expert on this particular database library but as far as I can tell, as soon as you fetchall() you can reuse the connection as much as you want (or the output would be missing a huge brick of data). But perhaps whoever added the second connection didn't bother to look at what they were doing (I know the "spec" requiring the data the second connection provides got added later)


Log in to reply