Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
c = con.cursor()
c.execute('drop table if exists stocks;')
create = ('create table stocks (date_ text, trans text, symbol text, '
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')
create = ('create table stocks (date_ text, trans text, symbol text, '
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')
def test_select_sets_description(self, con):
c = con.cursor()
c.execute('drop table if exists stocks;')
create = ('create table stocks (date_ text, trans text, symbol text, '
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')
c.execute('drop table if exists stocks;')
create = ('create table stocks (date_ text, trans text, symbol text, '
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')
c = con.cursor()
c.execute('drop table if exists stocks;')
create = ('create table stocks (date_ text, trans text, symbol text, '
'qty int, price float, vol float);')
c.execute(create)
i1 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14,1.1);" # noqa
i2 = "INSERT INTO stocks VALUES ('2006-01-05','BUY','GOOG',100,12.14,1.2);" # noqa
c.execute(i1)
c.execute(i2)
c.execute("select * from stocks")
expected = [
Description('date_', 6, None, None, None, None, True),
Description('trans', 6, None, None, None, None, True),
Description('symbol', 6, None, None, None, None, True),
Description('qty', 1, None, None, None, None, True),
Description('price', 3, None, None, None, None, True),
Description('vol', 3, None, None, None, None, True),
]
assert c.description == expected
c.execute('drop table if exists stocks;')