diff options
author | Zachary Sloan | 2013-03-26 22:18:33 +0000 |
---|---|---|
committer | Zachary Sloan | 2013-03-26 22:18:33 +0000 |
commit | 06367191cc7179a606c7533cead23c1de127eb13 (patch) | |
tree | 9d28a0856f11b7e5c41c4bfe5b3a7292dfb4d30c /wqflask/maintenance/quick_search_table.py | |
parent | 2d9ca98bcf19096fbfaeaa82b752c56640d70135 (diff) | |
download | genenetwork2-06367191cc7179a606c7533cead23c1de127eb13.tar.gz |
Created quick_search_table.py to create table with all of the
information needed for the the quick search features (which searches
across all datasets)
Diffstat (limited to 'wqflask/maintenance/quick_search_table.py')
-rw-r--r-- | wqflask/maintenance/quick_search_table.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/wqflask/maintenance/quick_search_table.py b/wqflask/maintenance/quick_search_table.py new file mode 100644 index 00000000..a337a543 --- /dev/null +++ b/wqflask/maintenance/quick_search_table.py @@ -0,0 +1,50 @@ +from __future__ import print_function, division, absolute_import + +import sys +sys.path.append("../../..") + +import sqlalchemy as sa +from sqlalchemy.dialects import mysql +from sqlalchemy.orm import scoped_session, sessionmaker, relationship, backref +from sqlalchemy.orm.exc import NoResultFound +from sqlalchemy.ext.declarative import declarative_base + +import zach_settings as zs + +Engine = sa.create_engine(zs.SQLALCHEMY_DATABASE_URI, + #encoding='utf-8', + #client_encoding='utf-8', + echo="debug", + ) + +Session = scoped_session(sessionmaker(bind=Engine)) #, extension=VersionedListener())) +#Xsession = Session() + +Base = declarative_base(bind=Engine) +Metadata = sa.MetaData() +Metadata.bind = Engine + + +class ProbeSet(Base): + __tablename__ = 'ProbeSet' + __table_args__ = {'autoload': True} + +def main(): + for ps in page_query(Session.query(ProbeSet)): #all() + #for ps in probe_sets: + print("--->", ps) + +def page_query(q): + """http://stackoverflow.com/a/1217947/1175849""" + offset = 0 + while True: + r = False + for elem in q.limit(1000).offset(offset): + r = True + yield elem + offset += 1000 + if not r: + break + +if __name__ == "__main__": + main()
\ No newline at end of file |