小编Nar*_*ali的帖子

Laravel 5.5错误基表或视图已存在:1050表'用户'已存在

产品规格:

  • Laravel版本:5.5.3
  • PHP版本:7.1
  • 数据库驱动程序和版本:MariaDB 10.1.26

描述:

C:/Users/user/code/blog/>php artisan migrate

[Illuminate\Database\QueryException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already exists (SQL: create table users (id int unsigned not null aut
o_increment primary key, name varchar(255) not null, email varchar(255) not null, password varchar(255) not null, remember_token varchar
(100) null, created_at timestamp null, updated_at timestamp null) default character set utf8mb4 collate utf8mb4_unicode_ci engine = InnoDB R
OW_FORMAT=DYNAMIC)

[PDOException]
SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'users' already …
Run Code Online (Sandbox Code Playgroud)

php mysql laravel-5 laravel-5.5

6
推荐指数
5
解决办法
3万
查看次数

如何从离线 plotly python jupyter notebook 中的选定点获取数据?

示例代码:

from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

import plotly.graph_objs as go

import numpy as np

N = 30
random_x = np.random.randn(N)
random_y = np.random.randn(N)

# Create a trace
trace = go.Scatter(
    x = random_x,
    y = random_y,
    mode = 'markers'
)

data = [trace]

# Plot and embed in ipython notebook!
iplot(data, filename='basic-scatter')
Run Code Online (Sandbox Code Playgroud)

[在此处输入图片说明]

如何从选择中获取 x、y 数据或索引的副本?

python plotly jupyter-notebook

6
推荐指数
1
解决办法
1449
查看次数

图表Js负量表

我需要以负值启动条形图比例,我正在使用2.7.0版本中的Chart Js。

图表必须从-10到100。

图片示例:

在此处输入图片说明

这是可能的?

var canvas = document.getElementById('myChart');
var data = {
    labels: ["Test"],
    datasets: [
        {
            label: "-10 to 100",
            backgroundColor: "rgba(255,99,132,0.2)",
            borderColor: "rgba(255,99,132,1)",
            borderWidth: 2,
            hoverBackgroundColor: "rgba(255,99,132,0.4)",
            hoverBorderColor: "rgba(255,99,132,1)",
            data: [100],
        }
    ]
};
var option = {
	scales: {
  	yAxes:[{
    		stacked:true,
        gridLines: {
        	display:true,
          color:"rgba(255,99,132,0.2)"
        }
    }],
    xAxes:[{
    		gridLines: {
        	display:false
        }
    }]
  }
};

var myBarChart = Chart.Bar(canvas,{
	data:data,
  options:option
});
Run Code Online (Sandbox Code Playgroud)
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.0/Chart.bundle.js"></script>
<canvas id="myChart" width="400" height="200"></canvas>
Run Code Online (Sandbox Code Playgroud)

Jsfiddle:https ://jsfiddle.net/LilNawe/Luaf2tm4/636/

javascript canvas bar-chart html5-canvas chart.js

3
推荐指数
1
解决办法
4379
查看次数

如何在列表中打印最多 n 个元素

我想在列表中打印最多 50 个元素

即如果列表中有 100 个元素,我只需要前 50 个。我目前的上述代码是

'Filter':switcheroo.get(zaxis,["None Selected"])[zaxis].unique().tolist()[:50]
Run Code Online (Sandbox Code Playgroud)

如果列表中有 25 个元素,我只需要 25 个。使用上述代码时出现错误。从其他帖子中我了解到以下代码是解决方案,但我无法理解如何使用我当前的代码实现它。

[x for _, x in zip(range(n), records)]
Run Code Online (Sandbox Code Playgroud)

如何从 Python 中的生成器或列表中获取前 N 个项目?

python

-3
推荐指数
1
解决办法
6252
查看次数

Spring + Hibernate手动创建事务,PROPAGATION_REQUIRED失败.BUG?

请不要建议我为此使用交易注意事项.

我遇到了一个与Spring处理事务有关的错误.

请看一下这两个测试用例,注释在代码中:

实体类例如:

@Entity
public class Person{
    @Id
    String name;
}
Run Code Online (Sandbox Code Playgroud)

使用的一些方法:

public TransactionStatus requireTransaction() {
        TransactionTemplate template = new TransactionTemplate();
        template.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
        return getTransactionManager().getTransaction(template);
}

public Session session() {
        return getRepository().session();
}

public PlatformTransactionManager getTransactionManager() {
        return getRepository().getTransactionManager();
}
Run Code Online (Sandbox Code Playgroud)

这是第一个测试,testA();

@Test
public void testA() throws InterruptedException {
        // We create the first transaction
        TransactionStatus statusOne = requireTransaction();

        // Create person one
        Person pOne = new Person();
        pOne.name = "PersonOne";
        session().persist(pOne);

        // ---> 111) NOTE! We do not commit! Intentionally! …
Run Code Online (Sandbox Code Playgroud)

spring hibernate transactions spring-transactions

-18
推荐指数
1
解决办法
1456
查看次数