def update(article, article_id): Session = openSession() session = Session() session.query(ArticleDto).filter(ArticleDto.art_id == article.article_id)\ .update({ArticleDto.title: article.title, ArticleDto.content: article.content}) session.commit()
def insert_many(): service = UserService() Session = openSession() session = Session() df = service.hook() print(df.head()) session.bulk_insert_mappings(UserDto, df.to_dict(orient="records")) session.commit() session.close()
def bulk(): Session = openSession() session = Session() cabbage_df = CabbageDf() df = cabbage_df.hook() print(df.head()) session.bulk_insert_mappings(CabbageDto, df.to_dict(orient='records')) session.commit() session.close()
def save(article): print('# ==============================================================') print(article) Session = openSession() session = Session() newArticle = ArticleDto(title = article['user_id'], content = article['content'], user_id = article['user_id'], item_id = article['item_id']) session.add(newArticle) session.commit()
from sklearn.model_selection import train_test_split from sklearn.model_selection import KFold # k value is understood as count from sklearn.model_selection import cross_val_score from sqlalchemy import func from pathlib import Path from sqlalchemy import and_, or_ from com_sba_api.util.file import FileReader from flask import jsonify from com_sba_api.ext.db import db, openSession import pandas as pd import json import os import pandas as pd import numpy as np Session = openSession() session = Session() class UserDao(UserDto): @classmethod def bulk(cls, user_dfo): dfo = user_dfo.create() print(dfo.head()) session.bulk_insert_mappings(cls, dfo.to_dict(orient="records")) session.commit() session.close() @staticmethod def save(user): session.add(user)
def delete(cls,art_id): Session = openSession() session = Session() data = cls.query.get(art_id) session.delete(data) session.commit()
def modify(article): Session = openSession() session = Session() session.add(article) session.commit()
def delete(cls,art_id): Session = openSession() session = Session() cls.query(ArticleDto.art_id == art_id).delete() session.commit()
def save(article): Session = openSession() session = Session() session.add(article) session.commit()