{"id":769,"date":"2010-08-06T14:26:13","date_gmt":"2010-08-06T19:26:13","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=769"},"modified":"2011-07-06T09:32:21","modified_gmt":"2011-07-06T14:32:21","slug":"python-script-to-print-out-table-data-in-namevalue-pairs","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2010\/08\/06\/python-script-to-print-out-table-data-in-namevalue-pairs\/","title":{"rendered":"Python script to print out table data in name\/value pairs"},"content":{"rendered":"<p>Simple today.  I just wanted to ensure I had this in case I need to cut and paste it later \ud83d\ude42<\/p>\n<pre lang=\"python\" line=\"1\">\r\n#!\/home\/oracle\/local\/bin\/python\r\n\r\nimport cx_Oracle, string\r\n\r\nconnection = cx_Oracle.connect(mode = cx_Oracle.SYSDBA)\r\n\r\ncursor = connection.cursor()\r\ncnt=cursor.execute(\"select * from v$database\")\r\n\r\ncolcount=len(cnt.description)\r\n\r\nfor row in cursor.fetchall():\r\n  print \"-----------------------------------------------\"\r\n  for col in range(colcount):\r\n    print string.ljust(cursor.description[col][0],40) + str(row[col])\r\n  print \"-----------------------------------------------\"\r\n\r\ncursor.close()\r\nconnection.close()\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Simple today. I just wanted to ensure I had this in case I need to cut and paste it later \ud83d\ude42 #!\/home\/oracle\/local\/bin\/python import cx_Oracle, string connection = cx_Oracle.connect(mode = cx_Oracle.SYSDBA) cursor = connection.cursor() cnt=cursor.execute(&#8220;select * from v$database&#8221;) colcount=len(cnt.description) for row&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2010\/08\/06\/python-script-to-print-out-table-data-in-namevalue-pairs\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[24,26],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/769"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=769"}],"version-history":[{"count":6,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/769\/revisions"}],"predecessor-version":[{"id":913,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/769\/revisions\/913"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=769"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}