КЛАСС МОДЕЛИ ТАБЛИЦЫ SQLALCHEMY

SQLALCHEMY, FLASK

  •                             
    CLASS SOMETABLE(DB.MODEL):
        ID = DB.COLUMN(DB.INTEGER, PRIMARY_KEY=TRUE, AUTOINCREMENT=TRUE)
    
        DEF __INIT__(SELF, *ARGS, **KWARGS):
            SUPER(SOMETABLE, SELF).__INIT__(*ARGS, **KWARGS)
    
        DEF __REPR__(SELF):
            RETURN '<SOMETABLE ID:{}>'.FORMAT(SELF.ID)
                                
                            
  • Автор

    Админ

Создание контекста приложения flask

shell, context, flask

  •                             
    @app.shell_context_processor
    def make_shell_context():
        return {'db': db}
                                
                            
  • Автор

    maxim

тест перед защитой

None

тест

None

  •                             
    CLASS SOMETABLE(DB.MODEL):
        ID = DB.COLUMN(DB.INTEGER, PRIMARY_KEY=TRUE, AUTOINCREMENT=TRUE)
    
        DEF __INIT__(SELF, *ARGS, **KWARGS):
            SUPER(SOMETABLE, SELF).__INIT__(*ARGS, **KWARGS)
    
        DEF __REPR__(SELF):
            RETURN '<SOMETABLE ID:{}>'.FORMAT(SELF.ID)
                                
                            
  • Автор

    Админ

Получение классов

python, class

  •                             
    #возвращает классы данного модуля
    def get_classes():
        return inspect.getmembers(sys.modules[__name__], inspect.isclass)
    #получить объект класса по названию
    def get_class(name):
        for i in get_classes():
            if i[0].lower() == name.lower():
                return i[1]
            else:
                return 'none'
                                
                            
  • Автор

    Админ

Для Ани спецом

Database

  •                             
    select Govno from Ass
                                
                            
  • Автор

    Gavno

left outer join SQL LINQ

c#, join, sql, linq, .net

  •                             
     var result = from stud in db.Student
                                 join card in db.PersonalStudentCard on stud.Login equals card.Login_Student into studCard
                                 from studCardJoined in studCard.DefaultIfEmpty()
                                 where studCardJoined.Login_Teacher == teach.Login
                                 join plan in db.AcademicPlan on studCardJoined.ID_AcademicPlan equals plan.ID into planStudCard
                                 from planStudCardJoined in planStudCard.DefaultIfEmpty()
                                 where planStudCardJoined.ID_Discipline == (comboDisc.SelectedItem as Discipline).ID
                                 select new
                                 {
                                     Login = stud.Login,
                                     Lastname = stud.Lastname,
                                     Middlename = stud.Middlename,
                                     Firstname = stud.Firstname,
                                     Rating= studCardJoined.Rating
                                 };
                                
                            
  • Автор

    annaKrutaya

Запрос с группировкой Linq

C#, linq, sql, t-sql

  •                             
     var queryDisc = from plan in db.AcademicPlan
    join card in db.PersonalStudentCard on plan.ID equals card.ID_AcademicPlan
    join stud in db.Student on card.Login_Student equals stud.Login
    join disc in db.Discipline on plan.ID_Discipline equals disc.ID
    where
    stud.ID_Group == (comboGroup.SelectedItem as Groups).KOD &&
    plan.Semester == (comboSemester.SelectedItem as AcademicPlan).Semester &&
    card.Login_Teacher == teach.Login
    group disc by new { disc.Name, disc.ID } into d
    select new { d.Key.ID, d.Key.Name };
                                
                            
  • Автор

    annaKrutaya