Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否可以使用RMySQL以编程方式加载SQL转储文件?_Mysql_R_Rmysql - Fatal编程技术网

是否可以使用RMySQL以编程方式加载SQL转储文件?

是否可以使用RMySQL以编程方式加载SQL转储文件?,mysql,r,rmysql,Mysql,R,Rmysql,我正在包的配置文件夹中以.sql转储文件的形式存储数据库结构(存储在inst/config)。 目前我使用的命令行需要输入密码: cat 'filename.sql' | mysql -p databasename 事实上,我建议用户如何使用此函数加载转储: loaddbstructure <- function(sqlfile = system.file("config/dump.sql",

我正在包的配置文件夹中以.sql转储文件的形式存储数据库结构(存储在
inst/config
)。 目前我使用的命令行需要输入密码:

cat 'filename.sql' | mysql -p databasename
事实上,我建议用户如何使用此函数加载转储:

loaddbstructure <- function(sqlfile = system.file("config/dump.sql",
                                                package="mypackagename", mustWork = TRUE)){
    message("This message gives 2 options to load the database structure.\n\n",
            "(1) If a user called 'R' is created in MySQL, you can run this from a shell command line: \n",
            sprintf("$ cat '%s' | mysql -u R -p tradeflows", sqlfile),
            "\n\n",
            "(2) Another option is to call this from a mysql client:\n",
            "mysql> connect tradeflows;\n",
            sprintf("mysql> source %s;", sqlfile))
}

loaddbstructure将连接凭据添加到位于
~/.my.cnf

[client]
user = R 
password = password
然后,可以使用调用system bash命令的R命令加载数据库转储(特定于Linux):


将连接凭据添加到位于
~/.my.cnf
中的:

[client]
user = R 
password = password
然后,可以使用调用system bash命令的R命令加载数据库转储(特定于Linux):


是否可以使用已建立的MySQL连接加载数据填充@Riedsio似乎加载数据填充无法加载.sql文件,只能加载
.csv
等数据文件。我想加载一个sql转储,该转储创建具有字段类型和索引的表结构。如果我错了,我会很高兴的。使用source命令怎么样?i、 e.从mysql提示符运行'source filename.sql'@Riedsio我在
~/.my.cnf
中的特定组中设置了密码,但我需要设置
[client]password=“my password”
以将密码发送到任何mysql客户端。是否可以使用已建立的mysql连接加载数据填充@Riedsio似乎加载数据填充无法加载.sql文件,只能加载
.csv
等数据文件。我想加载一个sql转储,该转储创建具有字段类型和索引的表结构。如果我错了,我会很高兴的。使用source命令怎么样?i、 e.从mysql提示符运行'source filename.sql'@Riedsio我在
~/.my.cnf
中的特定组中设置了密码,但我需要设置
[client]password=“my password”
以将密码发送到任何mysql客户端。