00 Create Schemas


In [1]:


In [1]:
import medareda_lib

def get_conn():
    return medareda_lib.get_conn()

In [16]:
def create_iPrice():
    conn = get_conn()
    cur = conn.cursor()
    cur.execute('''DROP TABLE IF EXISTS iPrice   ''')
    cur.execute('''CREATE TABLE IF NOT EXISTS iPrice  ( \
                 iPriceId SERIAL PRIMARY KEY, \
                 iDate timestamp,
                 status text,
                 date timestamp, symbol text, bid real, rate real, ask real)''')
    conn.commit()
    cur.close()
    conn.close()

In [2]:
def create_vPrice():
    conn = get_conn()
    cur = conn.cursor()
    cur.execute('''DROP TABLE IF EXISTS vPrice   ''')
    cur.execute('''CREATE TABLE IF NOT EXISTS vPrice  
                    ( vPriceId serial PRIMARY KEY, 
                      date timestamp, 
                      symbol text, 
                      price real,
                      combinedRate real)''')
    conn.commit()
    cur.close()
    conn.close()

In [6]:
def create_pPrice():
    conn = get_conn()
    c  = conn.cursor()
    c.execute('''DROP TABLE IF EXISTS pPrice   ''')

    c.execute('''CREATE TABLE IF NOT EXISTS pPrice  (  \
                          pPriceId SERIAL PRIMARY KEY, \
                          iPriceID integer, \
                          iDate timestamp, \
                          pStartDate timestamp, \
                          pEndDate timestamp, \
                          worker text, \
                          error text, \
                          date timestamp, symbol text, bid real, rate real, ask real)             ''')
      # no audit or market or type
    conn.commit()
    conn.close()

In [19]:
def create_dPrice():
    conn = get_conn()
    c  = conn.cursor()
    c.execute("DROP TABLE IF EXISTS dPrice ")
    c.execute('''CREATE TABLE IF NOT EXISTS dPrice  (\
                   dPriceId SERIAL PRIMARY KEY, \
                   iPriceId integer, \
                   iDate timestamp, \
                   pStartDate timestamp, \
                   pEndDate timestamp, \
                   date timestamp, symbol text, bid real, roll_ave real, ask real)''')
       # no audit or market or type

    conn.commit()
    conn.close()

In [10]:
def register_price():
    print 'register_price'
    conn = get_conn()
    c = conn.cursor()
    viewpoint = [('dPrice', 0),]
    c.execute("INSERT INTO vViewpoint (dtable, row) VALUES ('dPrice',0)" )
    conn.commit()

    conn.close()

In [4]:
def create_vViewpoint():
    conn = get_conn()
    c  = conn.cursor()
    c.execute('''DROP TABLE IF EXISTS vViewpoint   ''')
    c.execute('''CREATE TABLE IF NOT EXISTS vViewpoint ( vViewpointId SERIAL PRIMARY KEY, dtable text, row int)''')
       # id should be int

    conn.commit()
    conn.close()

In [17]:
create_iPrice()

In [20]:
create_dPrice()

In [7]:
create_pPrice()

In [8]:
create_vViewpoint()

In [11]:
register_price()


register_price

In [12]:
create_vPrice()

In [ ]: