示例#1
0
 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()
示例#2
0
 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()
示例#3
0
 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()
示例#4
0
 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()
示例#5
0
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)
示例#6
0
 def delete(cls,art_id):
     Session = openSession()
     session = Session()
     data = cls.query.get(art_id)
     session.delete(data)
     session.commit()
示例#7
0
 def modify(article):
     Session = openSession()
     session = Session()
     session.add(article)
     session.commit()
示例#8
0
 def delete(cls,art_id):
     Session = openSession()
     session = Session()
     cls.query(ArticleDto.art_id == art_id).delete()
     session.commit()
示例#9
0
 def save(article):
     Session = openSession()
     session = Session()
     session.add(article)
     session.commit()