<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andy Dixon &#187; Python</title>
	<atom:link href="http://www.andydixon.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.andydixon.com</link>
	<description>Do the Oblivious</description>
	<lastBuildDate>Wed, 08 Feb 2012 00:24:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Postgres and Python example</title>
		<link>http://www.andydixon.com/2012/01/08/postgres-and-python-example/</link>
		<comments>http://www.andydixon.com/2012/01/08/postgres-and-python-example/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 19:45:40 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[postgres]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[psycopg2]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.andydixon.com/?p=33</guid>
		<description><![CDATA[Here is an example of connecting to and retrieving data from postgres. It requires psycopg2 &#8211; this can be found via yum or apt&#8230; ï»¿#!/usr/bin/env python import psycopg2 def main(): connection = psycopg2.connect('host=server.domain.com dbname=database user=username password=password') mark = connection.cursor() query='SELECT * FROM tablename' mark.execute(query) record = mark.fetchall() for i in record: print i return if [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an example of connecting to and retrieving data from postgres.</p>
<p>It requires psycopg2 &#8211; this can be found via <strong>yum</strong> or <strong>apt</strong>&#8230;</p>
<pre>ï»¿#!/usr/bin/env python<br />
import psycopg2<br />
def main():<br />
    connection = psycopg2.connect('host=<strong>server.domain.com</strong> dbname=<strong>database</strong> user=<strong>username</strong> password=<strong>password</strong>')<br />
    mark = connection.cursor()<br />
    query='SELECT * FROM <strong>tablename</strong>'<br />
    mark.execute(query)<br />
    record = mark.fetchall()<br />
    for i in record:<br />
        print i<br />
    return</p>
<p>if __name__ == '__main__':<br />
    main()</p>
]]></content:encoded>
			<wfw:commentRss>http://www.andydixon.com/2012/01/08/postgres-and-python-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Seek and Destroy in Python</title>
		<link>http://www.andydixon.com/2012/01/04/seek-and-destroy-in-python/</link>
		<comments>http://www.andydixon.com/2012/01/04/seek-and-destroy-in-python/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 17:14:52 +0000</pubDate>
		<dc:creator>Andy</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[search]]></category>

		<guid isPermaLink="false">http://www.andydixon.com/?p=18</guid>
		<description><![CDATA[This will find and delete certain patterns &#8211; ie search a drive for specific things and delete them, or pass an option to empty .Trashes folders on a file server.. #!/usr/bin/env python import osâ€¨ import sysâ€¨ import string try:â€¨ searchString = sys.argv[1] â€¨except: searchString = â€ if (len(searchString) > 0):â€¨ if (searchString == â€˜-trashesâ€™):â€¨ print [...]]]></description>
			<content:encoded><![CDATA[<p><p>This will find and delete certain patterns &#8211; ie search a drive for specific things and delete them, or pass an option to empty .Trashes folders on a file server..</p>
</p>
<pre>
#!/usr/bin/env python
import osâ€¨
import sysâ€¨
import string
try:â€¨
    searchString = sys.argv[1]
â€¨except:
    searchString = â€

if (len(searchString) > 0):â€¨
    if (searchString == â€˜-trashesâ€™):â€¨
        print â€œFinding (and emptying) Trashesâ€¦.â€â€¨
        searchHandle = os.popen(â€˜find . -name â€œ.Trashesâ€ -exec rm -fr {}/* \;â€™)â€¨
        search = searchHandle.read()â€¨
        searchHandle.close()â€¨
        results = search.split(â€˜\nâ€™)â€¨
    else:â€¨
        if (searchString == â€˜-cleanupâ€™):â€¨
            print â€˜Doing a scrub, this can take a whileâ€¦â€™â€¨
            searchHandle = os.popen(â€˜find . -name â€œDownloadsâ€ -exec rm -fr {}/* \;â€™)â€¨
            search = searchHandle.read()â€¨
            searchHandle.close()â€¨
            results = search.split(â€˜\nâ€™)â€¨
            searchHandle = os.popen(â€˜find . -name â€œ.Trashesâ€ -exec rm -fr {}/* \;â€™)â€¨
            search = searchHandle.read()â€¨
            searchHandle.close()â€¨
            results = search.split(â€˜\nâ€™)â€¨
            searchHandle = os.popen(â€˜find . -name â€œMail Downloadsâ€ -exec rm -fr {}/* \;â€™)â€¨
            search = searchHandle.read()â€¨  searchHandle.close()â€¨ results = search.split(â€˜\nâ€™)
         else:
             searchHandle = os.popen(â€˜find . -name â€œâ€˜ + searchString + â€˜â€ -exec rm -fr {} \;â€™)â€¨
             search = searchHandle.read()â€¨searchHandle.close()â€¨results = search.split(â€˜\nâ€™)
else:
    print â€œnukeall finds and removes (recursively) the specified file(s) in the current folder.â€â€¨
    print â€œExample:â€â€¨ print â€œ â€œ+sys.argv[0]+â€ .DS_Storeâ€â€¨ print â€œ â€œ+sys.argv[0]+â€ *.tmpâ€â€¨
    print â€œ â€œ+sys.argv[0]+â€ .*â€â€¨
    print â€œ\nâ€â€¨ print â€œYou can also pass the -trashes option which will search and empty. Trashes folders which is useful on file servers.â€â€¨
    print â€œ\nâ€â€¨ print â€œVersion 1.0 â€“ Andy Dixon â€“ Bug reports to: andy@andydixon.comâ€
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.andydixon.com/2012/01/04/seek-and-destroy-in-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

