def show_index(): engine = EngineFactory.create_engine_to_test_so() conn = engine.connect() text_sql = 'show index from {table_name}'.format( table_name=PostsRecord.__tablename__) s = text(text_sql) conn.execute(s) conn.close()
def delete_score_view_count_index(): try: engine = EngineFactory.create_engine_to_test_so() conn = engine.connect() index_name = "score_view_count_index" text_sql = 'alter table `{table_name}` drop index `{index_name}`'.format( table_name=PostsRecord.__tablename__, index_name=index_name) s = text(text_sql) conn.execute(s) conn.close() except: traceback.print_exc()
def add_score_index(): try: engine = EngineFactory.create_engine_to_test_so() conn = engine.connect() index_name = "score_index" text_sql = 'alter table {table_name} add index {index_name}(score)'.format( table_name=PostsRecord.__tablename__, index_name=index_name) s = text(text_sql) conn.execute(s) conn.close() except: traceback.print_exc()
user.creation_date = self.creation_date user.display_name = self.display_name user.last_access_date = self.last_access_date user.views = self.views user.web_site_url = self.web_site_url user.location = self.location user.about_me = self.about_me user.age = self.age user.up_votes = self.up_votes user.down_votes = self.down_votes user.email_hash = self.email_hash return user if __name__ == "__main__": engine = EngineFactory.create_engine_to_test_so() metadata = MetaData(bind=engine) # create all the table by model Base.metadata.create_all(bind=engine)