让我们查看查询的各个部分
插入
第一个问题是您的 insert
语句。您写道:
insertInto(Tables.USER_ORGANIZATION_ROLE.asterisk(), ...)
但是JOOQ API中没有这样的方法。你为什么这样写? dslContext.InterTinto(table<? =“ https://www.jooq.org/javadoc/latest/org.jooq/org/jooq/qualifyasterask.html” rel =“ nofollow noreforrer”>
。 org.jooq.qualififiedapstrifififed.qualifififedask.qualifyAstersk
您可能使用了 asterisk()
方法,因为您认为这将以某种方式映射到所有列中?但是您也不使用 user_organization_role。*
作为SQL查询中的表达式,那为什么要这呢?
为什么不直接翻译您的原始查询:
// I'm just going to assume the usual static imports, to reduce "noise"
insertInto(USER_ORGANIZATION_ROLE,
USER_ORGANIZATION_ROLE.ID_USER,
USER_ORGANIZATION_ROLE.ID_ORGANIZATION,
USER_ORGANIZATION_ROLE.ID_ROLE,
USER_ORGANIZATION_ROLE.ID_WORKSPACE)
插入。选择
您尝试将选择
表达式直接传递到 insertinto()
方法,但是同样,JOOQ API没有具有任何此类方法,该方法与表一起选择选择
。 似乎很清楚?
create.insertInto(table)
.select(select)
.execute();
因此,被翻译成您的用例:
// The WITH .. SELECT
Select<Record4<.., .., .., ..>> select = ...
// The code from before
insertInto(USER_ORGANIZATION_ROLE,
USER_ORGANIZATION_ROLE.ID_USER,
USER_ORGANIZATION_ROLE.ID_ORGANIZATION,
USER_ORGANIZATION_ROLE.ID_ROLE,
USER_ORGANIZATION_ROLE.ID_WORKSPACE)
// Put your WITH .. SELECT in here
.select(select)
此时,还值得注意的是,Jooq中的每个查询都是 Dynamic SQL查询,因此,如果有助于更好地构造和理解查询的各个部分,则没有什么可以阻止您将零件分配给本地变量。
使用..选择
该部分还有更多问题,包括:
-
table(name(“ cte_0”))。字段(“ id_role”)
不起作用。table&lt;?&gt;
您正在创建这种方式对id_role
字段一无所知,因此它无法查找。 中进行了记录。即返回的表不知道其字段引用,即fields.fields.fields()返回一个空数组。
您必须使用
field(name(“ CTE_0”,“ ID_ROLE”))
而不是 -
应将数据类型添加到您的字段预测中,因此执行后,您可以将类型的安全性和正确的投影添加到您的字段预测中查询,即这会更好:
字段(name(“ cte_0”,“ id_role”),id_role.getDatatype())
可能还有其他问题
评论何时使用JOOQ
JOOQ在复杂的查询中非常有效,尤其是当它们动态时。在某些情况下,即当涉及派生表或CTE时,JOOQ仍然可以处理复杂性,但是内部DSL方法使SQL语句有点难以读 /写入,主要是因为不可能参考尚未尚未的表格被宣布。编写静态SQL时,整个类型的安全参数会因派生表或CTE而失败,即非动态SQL。
因此,在Jooq世界中,每当您使用派生表或CTE时,请考虑:
- 是否可以使用本机SQL作为复杂部分,例如 plin sql templating 或视图等(严重的是,仅仅因为您使用的是Jooq并不意味着您意味着您必须将其用于每个查询)
- 是否可以将查询重新编写到更简单的内容(通常更好地使用JOOQ)是否可以
将查询重写为更简单的查询
似乎是您的查询似乎是做同样的事情吗?
insert into user_organization_role (
id_user, id_organization, id_role, id_workspace
)
select distinct
ur.id_user,
ur0.id_organization,
ur0.id_role,
ur0.id_workspace
from
user_organization_role ur,
user_orgainzation_role ur0
where ur.id_user <> 0
and ur0.id_user = 0
and (ur.id_user, ur0.id_organization, ur0.id_role, ur0.id_workspace) not in (
select id_user, id_organization, id_role, id_workspace
from user_organization_role
where id_user <> 0
)
我认为您首先不需要CTE。这似乎完全等效。我不太确定用例。您似乎在关系表上操作,并为每个尚未有此的用户自动在“默认”组织/角色/工作区中添加关系。因此,也许经典插入忽略
甚至会更好吗?即喜欢这个?
insert ignore into user_organization_role (
id_user, id_organization, id_role, id_workspace
)
select distinct
ur.id_user,
ur0.id_organization,
ur0.id_role,
ur0.id_workspace
from
user_organization_role ur,
user_orgainzation_role ur0
where ur.id_user <> 0
and ur0.id_user = 0
这是假设4列形成 unique
约束
在您的情况下
class User extends Authenticatable
{
public function cart_items() {
return $this->belongsToMany(Product::class, 'carts');
}
}
class Product extends Model
{
public function users()
{
return $this->belongsToMany(User::class, 'carts');
}
}
,您可以使用以下方式同步/附加产品:
// Products IDS
$product_ids= [1, 2];
// Then use
$user->cart_items()->attach($product_ids); // adds to existing
// OR
$user->cart_items()->sync($product_ids); // only this will be in your cart
要获取可登录用户的购物车项目,
foreach($user->cart_items as $cart_item) {
// do stuff
}
您可以使用
foreach(auth()->user()->cart_items as $cart_item) {
// do stuff
}
$query = "INSERT INTO carros (marca, modelo, submodelo, combustivel, mesReg, anoReg, quilometros, cilindrada, potencia, aceitaRetoma, cor, tipoCor, tipoCaixa, nPortas, lotacao, nMudancas, registo, origem, livroRevisoesCompleto, naoFumador, segundaChave, anunciante, imagemPrincipal, imagemPrincipalLoc, imagemUm, imagemUmLoc, imagemDois, imagemDoisLoc, imagemTres, imagemTresLoc, imagemQuatro, imagemQuatroLoc, imagemCinco, imagemCincoLoc, imagemSeis, imagemSeisLoc, imagemSete, imagemSeteLoc, userid) VALUES (UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?),UPPER(?))";
而不是:
$query = "INSERT INTO carros (marca, modelo, submodelo, combustivel, mesReg, anoReg, quilometros, cilindrada, potencia, aceitaRetoma, cor, tipoCor, tipoCaixa, nPortas, lotacao, nMudancas, registo, origem, livroRevisoesCompleto, naoFumador, segundaChave, anunciante, imagemPrincipal, imagemPrincipalLoc, imagemUm, imagemUmLoc, imagemDois, imagemDoisLoc, imagemTres, imagemTresLoc, imagemQuatro, imagemQuatroLoc, imagemCinco, imagemCincoLoc, imagemSeis, imagemSeisLoc, imagemSete, imagemSeteLoc, userid) VALUES (UPPER(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?))";
因为upper()只能接受一个参数。
我通过使瓷砖背景颜色与边框颜色匹配,然后用我的脚本而不是瓷砖的背景颜色设置文本的背景来解决此问题。这样,当创建缝隙时,它匹配边框颜色,看起来并不奇怪。现在,它在所有尺度上看起来都正确。它没有处理非编写图像,但是所有拉的图像均已自行折射到我的PHP中的正确尺寸。
window.onload = () => {
var colors = ['#ffffff', '#ffbd4b', '#ff634b', '#4b9fff'];
var nowhitecolors = ['#ffbd4b', '#ff634b', '#4b9fff'];
document.querySelectorAll('.blog_tile').forEach(
el => {
var randcolor = colors[Math.floor(Math.random() * colors.length)];
el.style.backgroundColor = '#ffffff';
el.children[1].style.backgroundColor = randcolor;
if (randcolor ==='#ffffff') {
var randnowhitecolors = nowhitecolors[Math.floor(Math.random() * nowhitecolors.length)];
el.style.borderColor = randnowhitecolors;
el.children[0].style.borderColor = randnowhitecolors;
el.style.backgroundColor =randnowhitecolors;
el.style.color = randnowhitecolors;
};
}
);
};
.blog_preview_container {
grid-row: 2;
grid-column: 1;
height: 354px;
display: flex;
flex-flow: row wrap;
justify-content: center;
column-gap: 40px;
row-gap: 40px;
}
.blog_tile {
height: 340px;
width: 240px;
margin-top: 0px;
border-width: 6px;
border-style: solid;
border-radius: 6px;
box-shadow: 4px 4px 6px rgba(0, 0, 0, 0.65);
color: white;
display: inline;
cursor: pointer;
transform: scale(1);
}
.blog_tile:hover {
transform: scale(1.04);
}
.blog_tile img {
height: 164px;
width: 240px;
padding: 0px;
margin: 0px;
object-fit: cover;
border-bottom-width: 6px;
border-bottom-style: solid;
}
.blog_tile p {
height: 138px;
font-family: 'nunito', sans-serif;
font-size: 1rem;
font-weight: 900;
line-height: 22px;
margin: 0;
padding: 16px;
}
<body>
<div class="blog_preview_container">
<div class="blog_tile">
<img class="blog_tile_image" src="https://example.com/img_location">
<p class="blog_tile_text">Text Goes Here</p>
</div>
</div>
</body>
在所有屏幕尺寸上看起来都很棒,没有更多的空白!
我们可以做合并
out = df1.merge(df2, on = 'ID', suffixes = ('','_x')).\
query('date<=date_x').sort_values('date').drop_duplicates('ID',keep='last')[df1.columns]
Out[272]:
ID date cumulative_sales
1 1 2020-01-03 15
当它是吞噬蜡烛时,您使用的吞噬变量将为 true
。
因此,直接在警报调用中使用变量。
alertcondition(bullishEngulfing, title = "Bullish Engulfing", message = "[CurrencyPair] [TimeFrame], Bullish candle engulfing previous candle")
alertcondition(bearishEngulfing, title = "Bearish Engulfing", message = "[CurrencyPair] [TimeFrame], Bearish candle engulfing previous candle")
由于缺少UNIX插座,因此系统上的PHP似乎无法正确配置,因为连接尝试失败。
检查unix_socket的位置,例如使用命令行客户端:
MariaDB [(none)]> \s
--------------
<snip>
UNIX socket: /tmp/mysql.sock
<snap>
现在确保MySQLI的PHP设置具有相同的设置,例如使用
php -i | grep socket
或检查您的PHP配置文件。
这是由于浮点类型的NAN所致。
您可以使用 fillna
使NANS 0:
data['ID'] = pd.to_numeric(data['ID'], errors='coerce').fillna(0, downcast='infer')
或将NAN保持为新整数NA,使用 Convert_dtypes
:
data['ID'] = pd.to_numeric(data['ID'], errors='coerce').convert_dtypes()
您可以尝试将文档根目录设置为CPANEL域设置页面上的“公共”目录。
或者,您可以使用.htaccess文件;
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !public/
RewriteRule (.*) /public/$1 [L]
您可以使用列表理解列表:
C = [np.append(x, B[i]) for i, x in enumerate(A)]
输出
[array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 2, 0]),
array([0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 4, 0, 8]),
array([0, 0, 0, 0, 0, 0, 0, 0, 1, 6, 1, 0, 9])]
我相信您正在寻找的是UpSert操作:
https://wiki.postgresql.org/wiki/upsert
健康)状况?数据库具有一组工具,例如交易和锁,以帮助您解决这些问题。
我认为了解包括和扩展的意图很重要:
“包含关系旨在重复使用的行为
另一种用例,而扩展关系的目的是
在现有用例中添加<的零件以及用于建模的可选系统服务的”(OverGaard和Palmkvist,用例:模式和蓝图。韦斯利,2004)。
)
。用例。
扩展= 添加(不重复使用)功能,也 note 可选功能。
1。将 new 功能添加到用例(是否可选)
2。任何可选用例(是否存在)。
摘要:
包括=功能重复使用
扩展=新的和/或可选功能,
您通常会发现扩展的第二个用法(即可选功能),因为如果功能不是可选的,那么大多数时候它就内置在用例本身中,而不是扩展。至少那是我的经历。 (朱利安·C(Julian C)指出,当项目进入第二阶段时,您有时会看到第一个用法(即添加新功能)。
问题是文件名。不支持完整的结肠。因此,相反,我将其格式化为下面的格式。
现在正在工作。
谢谢,@martin指出了错误。
The issue was with the filename. Full colons were not supported. So instead appending the full timestamp, I've formatted it as below.
And it's working now.
Thanks, @Martin for pointing out the mistake.
python ftplib ftp.rename()在某些服务器中投掷错误