Beispiel #1
0
    def test_table_columns(self):
        self.db.cursor().execute("create table options (date text, trans text, symbol text, qty real, price real, PRIMARY KEY (symbol, trans) );")
        self.assertEqual(utils.table_columns(self.db.cursor(), "options"),
                         [(0, u'date', u'text', 0, None, 0), (1, u'trans', u'text', 0, None, 1), (2, u'symbol', u'text', 0, None, 1), (3, u'qty', u'real', 0, None, 0), (4, u'price', u'real', 0, None, 0)])
        self.db.cursor().execute("create table futures (date text, trans text, symbol text PRIMARY KEY , qty real, price real );")
        self.assertEqual(utils.table_columns(self.db.cursor(), "futures"),
                         [(0, u'date', u'text', 0, None, 0), (1, u'trans', u'text', 0, None, 0), (2, u'symbol', u'text', 0, None, 1), (3, u'qty', u'real', 0, None, 0), (4, u'price', u'real', 0, None, 0)])

        #Now test finding primary keys
        self.assertEqual(utils.primary_key(self.db, "options"), (u'symbol',u'trans'))
        self.assertEqual(utils.primary_key(self.db, "futures"), (u'symbol',))
Beispiel #2
0
 def test_primary_key_with_uniques(self):
     self.db.cursor().execute("create table options (date text, trans text, symbol text, qty real, price real, uuid text UNIQUE, PRIMARY KEY (symbol, trans) );")
     self.assertEqual(utils.primary_key(self.db, "options"), (u'symbol', u'trans'))