-
-
Save munro/3686e3b060c2cd7959350ea8bf77ff2c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
from sqlalchemy import Column, DateTime, Integer, MetaData, Numeric, Table, select | |
meta = MetaData() | |
def stock_table(company): | |
return Table( | |
'stock_{}'.format(company), | |
meta, | |
Column('id', Integer), | |
Column('volume', Integer), | |
Column('price', Numeric), | |
Column('date', DateTime) | |
) | |
aapl = stock_table('aapl') | |
engine.execute( | |
select(['*']) | |
.select_from(aapl) | |
.where(aapl.c.date >= datetime.now() - timedelta(days=7)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment