def setUp(self):
        self.conn = create_sqlite_table()

        self.table = sql_table(
            'testtable',
            ['i', 'msg', 'price'],
            [dshape('int32'), dshape('string'), dshape('float64')],
            self.conn)

        self.col_i = sql_column('testtable', 'i',
                                dshape('3 * int32'),
                                self.conn)
        self.col_msg = sql_column('testtable', 'msg',
                                  dshape('3 * string'),
                                  self.conn)
        self.col_price = sql_column('testtable', 'price',
                                    dshape('3 * float64'),
                                    self.conn)

        test_data = np.array(data, dtype=[('i', np.int32),
                                          ('msg', '|S5'),
                                          ('price', np.float64)])
        self.np_i = test_data['i']
        self.np_msg = test_data['msg']
        self.np_price = test_data['price']
Example #2
0
    def setUp(self):
        self.conn = create_sqlite_table()

        self.table = sql_table(
            'testtable',
            ['i', 'msg', 'price'],
            [dshape('int32'), dshape('string'), dshape('float64')],
            self.conn)

        self.col_i = sql_column('testtable', 'i',
                                dshape('3, int32'),
                                self.conn)
        self.col_msg = sql_column('testtable', 'msg',
                                  dshape('3, string'),
                                  self.conn)
        self.col_price = sql_column('testtable', 'price',
                                    dshape('3, float64'),
                                    self.conn)

        test_data = np.array(data, dtype=[('i', np.int32),
                                          ('msg', '|S5'),
                                          ('price', np.float64)])
        self.np_i = test_data['i']
        self.np_msg = test_data['msg']
        self.np_price = test_data['price']
        (4,  "Gilbrecht", 17),
        (8,  "Bertrand", 48),
        (16, "Janssen", 32),
    ]

    conn = db.connect(":memory:")
    c = conn.cursor()
    c.execute("""create table MyTable
                 (id INTEGER, name TEXT, age INTEGER)""")
    c.executemany("""insert into MyTable
                     values (?, ?, ?)""", data)
    conn.commit()
    c.close()

    return conn

conn = create_sqlite_table()

# Describe the columns. Note: typically you would describe column
# with variables for the column size, e.g. dshape('a * int32')
table = sql_table('MyTable',
                  ['id', 'name', 'age'],
                  [dshape('int32'), dshape('string'), dshape('float64')],
                  conn)

# Prints details about table
print(table)

# Eval to print values
print(blaze.eval(table[:, 'id']))