select * from student where totalDays-presentDays > 50;
我使用sequelize执行上述查询。
我尝试了以下代码。
where:
{
StudentDB.Sequelize.literal(totalDays-presentDays):
{
[Op.gt]:50
}
}
但它给出的错误就像意外的令牌'。在数据库名称和Sequelize关键字。
我也试过了。
attributes: ['ID', 'Name', 'totalDays','presentDays', [StudentDB.Sequelize.literal('(totalDays - presentDays)'), 'absentDays']],
where:{
absentDays:{
[Op.gt]:50
}
}
答案 0 :(得分:1)
假设您将表名定义为学生(不是变量定义,您在模型中的定义)
所以看起来应该是这样的:
import numpy as np
import scipy as sp
from sklearn.datasets import make_regression
from scipy.optimize import minimize
import matplotlib.pyplot as plt
%matplotlib inline
from numpy.linalg import norm
def generate_data(nsamples, nfeatures, variance=1):
'''Generates a data matrix of size (nsamples, nfeatures)
which defines a linear relationship on the variables.'''
X, y = make_regression(n_samples=nsamples, n_features=nfeatures,\
n_informative=nfeatures,noise=variance)
X[:,0] = np.ones(shape=(nsamples)) # add bias terms
return X, y