Create Schemas


In [1]:
import sqlite3

In [2]:
in_db = 'in.db'
data_db = 'data.db'
view_db = 'view.db'

In [3]:
conn = sqlite3.connect(in_db)
c  = conn.cursor()
c.execute( '''DROP TABLE IF EXISTS iPrice   ''' )
c.execute('''CREATE TABLE IF NOT EXISTS iPrice  ( \
                 iPriceId INTEGER PRIMARY KEY, \
                 iDate date,
                 status text,
                 date date, symbol text, bid real, rate real, ask real)''')
   # no audit or market or type
conn.commit()
conn.close()

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

conn.commit()
conn.close()

In [5]:
data_db = 'data.db'
conn = sqlite3.connect(data_db)
c  = conn.cursor()
c.execute('''DROP TABLE IF EXISTS pPrice   ''')

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

vViewpoint


In [6]:
conn = sqlite3.connect(view_db)
c  = conn.cursor()
c.execute('''DROP TABLE IF EXISTS vViewpoint   ''')
c.execute('''CREATE TABLE IF NOT EXISTS vViewpoint ( vViewpointId INTEGER PRIMARY KEY, dtable text, row int)''')
   # id should be int

conn.commit()
conn.close()

In [7]:
conn = sqlite3.connect(view_db)
c  = conn.cursor()
c.execute('''DROP TABLE IF EXISTS vPrice   ''')
c.execute('''CREATE TABLE IF NOT EXISTS vPrice  ( vPriceId INTEGER PRIMARY KEY, date timestamp, symbol text, price real)''')
   # no audit or market or type    unique key
#c.execute('''INSERT INTO vPrice (date, symbol, price) VALUES ('2000-01-01', 'VOD',10.2)''')
conn.commit()
conn.close()

In [ ]:


In [ ]:


In [ ]: