Done unit 14 d2
[tm351-notebooks.git] / notebooks / Transactions-dave.ipynb
1 {
2 "metadata": {
3 "name": "",
4 "signature": "sha256:311f2b2a75020242bf012374bf39a33d311cbe438684511fa7dec5ea8b5eb362"
5 },
6 "nbformat": 3,
7 "nbformat_minor": 0,
8 "worksheets": [
9 {
10 "cells": [
11 {
12 "cell_type": "code",
13 "collapsed": false,
14 "input": [
15 "import psycopg2 as pg;from pandas import read_sql_query as psql;from pandas.io.sql import execute as psqlx\n",
16 "dave = pg.connect(\"dbname='tm351test' host='localhost' user='test' password='test' \")"
17 ],
18 "language": "python",
19 "metadata": {
20 "activity": false
21 },
22 "outputs": []
23 },
24 {
25 "cell_type": "code",
26 "collapsed": false,
27 "input": [
28 "psqlx(\"UPDATE cars SET price=59000 WHERE id=1\",dave)\n",
29 "psql(\"SELECT * FROM cars WHERE id=1\",dave)"
30 ],
31 "language": "python",
32 "metadata": {
33 "activity": false
34 },
35 "outputs": []
36 },
37 {
38 "cell_type": "code",
39 "collapsed": false,
40 "input": [
41 "dave.commit()\n",
42 "psql(\"SELECT * FROM cars WHERE id=1\",dave)"
43 ],
44 "language": "python",
45 "metadata": {
46 "activity": false
47 },
48 "outputs": []
49 },
50 {
51 "cell_type": "code",
52 "collapsed": false,
53 "input": [],
54 "language": "python",
55 "metadata": {
56 "activity": false
57 },
58 "outputs": []
59 }
60 ],
61 "metadata": {}
62 }
63 ]
64 }