X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=complete.ipynb;h=735b78f70fc97f202cfdcdd90b64d3cb12b106e0;hb=fa101ebf71cd46c51df29eac35a001f60dd6434e;hp=bd272eb7ad705ecee8787fc5aa3eaaa633b1f3fb;hpb=4501f68fa04a34934ff3c3ec8e9ddf43e060c5e5;p=dmarc.git diff --git a/complete.ipynb b/complete.ipynb index bd272eb..735b78f 100644 --- a/complete.ipynb +++ b/complete.ipynb @@ -315,23 +315,34 @@ "metadata": { "collapsed": false }, + "outputs": [], + "source": [ + "conn = psycopg2.connect(host=config['database']['server'],\n", + " database=config['database']['database'], \n", + " user=config['database']['username'], \n", + " password=config['database']['password'])" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { "text/plain": [ - "datetime.datetime(2016, 3, 29, 23, 59, 59)" + "datetime.datetime(2016, 3, 30, 23, 59, 59)" ] }, - "execution_count": 12, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "with psycopg2.connect(host=config['database']['server'],\n", - " database=config['database']['database'], \n", - " user=config['database']['username'], \n", - " password=config['database']['password']) as conn:\n", + "with conn:\n", " with conn.cursor() as cur:\n", " cur.execute('select max(report_metadata_date_range_end) from reports')\n", " results = cur.fetchall()\n", @@ -341,7 +352,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": { "collapsed": false }, @@ -349,10 +360,10 @@ { "data": { "text/plain": [ - "('OK', [b'178'])" + "('OK', [b'179'])" ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -367,7 +378,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": { "collapsed": false }, @@ -375,10 +386,10 @@ { "data": { "text/plain": [ - "('SINCE 27-Mar-2016', 'OK', [b'169 170 171 172 173 174 175 176 177 178 179'])" + "('SINCE 28-Mar-2016', 'OK', [b'172 173 174 175 176 177 178 179 180'])" ] }, - "execution_count": 14, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -394,7 +405,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": { "collapsed": false }, @@ -402,20 +413,18 @@ { "data": { "text/plain": [ - "['1458957186.548175',\n", - " '2150510829392606201',\n", - " '68aad5080a774e2c997d159b546569b9@hotmail.com',\n", - " '1459129809.695034',\n", + "['1459129809.695034',\n", " '16143280651570354241',\n", " '8c177254c3cb41869dc3afab59f74c76@hotmail.com',\n", " '15410706527896810898',\n", " '1459216304.582931',\n", " '15497495941279624940',\n", " '1459302353.261157',\n", - " '7773a696f4a54f1e8c01f4644fbb94ee@hotmail.com']" + " '7773a696f4a54f1e8c01f4644fbb94ee@hotmail.com',\n", + " '15185964531645951164']" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -428,7 +437,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": { "collapsed": false }, @@ -439,7 +448,7 @@ "('BYE', [b'Logging out'])" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -455,21 +464,9 @@ "metadata": { "collapsed": false }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "write 1459302353.261157\n", - "write 7773a696f4a54f1e8c01f4644fbb94ee@hotmail.com\n" - ] - } - ], + "outputs": [], "source": [ - "with psycopg2.connect(host=config['database']['server'],\n", - " database=config['database']['database'], \n", - " user=config['database']['username'], \n", - " password=config['database']['password']) as conn:\n", + "with conn:\n", " with conn.cursor() as cur:\n", " for report in dmarc_reports:\n", " cur.execute('select id, report_metadata_report_id from reports where report_metadata_report_id = %s;', \n", @@ -482,12 +479,14 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 19, "metadata": { "collapsed": true }, "outputs": [], - "source": [] + "source": [ + "conn.close()" + ] } ], "metadata": {