小编Cra*_*000的帖子

将 csv 文件从 mySQL (MariaDB) 导出到目标文件夹时权限被拒绝

我的理解是,默认情况下导出文件(例如 csv)MariaDB仅限于指定的文件夹。tmp因此,到目前为止,我一直在该文件夹中访问导出的文件。我想问是否有办法将其更改为另一个文件夹,即/home/user/projects?我使用 Raspbian Stretch 作为我的操作系统。作为我的 e 的 root 用户SQL databas,我检查了我是否拥有完全的授予权限。

+---------------------------------------------------------------------+
| Grants for root@localhost                                           |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'%' TO 'root'@'localhost' WITH GRANT OPTION       |
+---------------------------------------------------------------------+
Run Code Online (Sandbox Code Playgroud)

但是,当我使用 查询时 MariaDB [mydatabase]> SELECT * from table1 into outfile '/home/user/projects/file1.csv';,出现以下错误:

ERROR 1 (HY000): Can't create/write to file '/home/user/projects/file1.csv' (Errcode: 13 "Permission denied"),

我还可以做些什么才能将文件导出到我选择的文件夹中?

更新:到目前为止,我尝试了 chmod 755 和 …

mysql database mariadb raspberry-pi

4
推荐指数
1
解决办法
6486
查看次数

从另一个脚本启动python脚本,并在subprocess参数中使用参数

要启动一个Python脚本(它是需要用于运行OLED显示器)从终端,我必须使用下面的bash命令:python demo_oled_v01.py --display ssd1351 --width 128 --height 128 --interface spi --gpio-data-command 20。之后的那些参数.py很重要,否则,脚本将使用默认设置运行,而在我的情况下,脚本将不会使用默认设置启动。因此,需要那些参数。

当我需要从另一个python脚本启动脚本(而不是在终端上使用bash命令)时,就会出现问题。从父脚本启动我的python脚本之一。我用过:

import subprocess # to use subprocess 

p = subprocess.Popen(['python', 'demo_oled_v01.py --display ssd1351 --width 128 --height 128 --interface spi --gpio-data-command 20'])
Run Code Online (Sandbox Code Playgroud)

在我的父脚本中,但出现错误说明:

python: can't open file 'demo_oled_v01.py --display ssd1351 --width 128 --height 128 --interface spi --gpio-data-command 20': [Errno 2] No such file or directory

我怀疑在--display ssd1351 --width 128 --height 128 --interface spi --gpio-data-command 20之后添加参数 .py可能会导致启动脚本困难。如前所述,这些参数对于我来说是必不可少的,包括在终端上使用bash命令启动时。如何使用带有必需参数的子进程来启动此脚本?

python bash subprocess

4
推荐指数
3
解决办法
4236
查看次数

在极轴上的两条线之间着色一段(matplotlib)

目前,我有一个用线条指示日出(蓝色)、中午(红色)、日落(橙色)和物体(绿色)方向的图。我想在日出和日落之间创建一个黄色阴影区域。我想到了这个plt.fill方法,但是当我添加plt.fill_between(theta1, theta2, R1, alpha=0.2). 我认为那是因为两条线不相交。我当前的极轴图如下所示:

在此处输入图片说明

脚本的相关部分是:

    #for object
    theta0 = np.deg2rad([190, 190])
    print ("theta0= %s" %theta0)    
    R0 = [0,0.4]

    #for sunrise
    theta1 = np.deg2rad([105, 105])
    print ("theta1= %s" %theta1)    
    R1 = [0,1]

    #for sunset
    theta2 = np.deg2rad([254, 254])
    print ("theta2= %s" %theta2)    
    R1 = [0,1]

    #for midday 
    theta3 = np.deg2rad([0.2, 0.2])
    print ("theta3= %s" %theta3)    
    R3 = [0,1]

    ax.set_theta_zero_location("S")
    ax.set_theta_direction(-1)

    ax.plot(theta1,R1, theta2, R1, theta0, R0, lw=5)

    #plt.fill_between(theta1, theta2, R1, alpha=0.2) #does not work


    plt.savefig('plot.png')
Run Code Online (Sandbox Code Playgroud)

我还想过使用中午的方位角,然后使用宽度,根据日落和日出之间的角度差计算,然后使用这些来生成阴影区域。我该怎么做呢?我只想要日出和日落之间的黄色阴影区域,因此我认为width …

python matplotlib

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

标签 统计

python ×2

bash ×1

database ×1

mariadb ×1

matplotlib ×1

mysql ×1

raspberry-pi ×1

subprocess ×1