如何在 Julia 中连接到 MySQL 数据库 [英] How to connect to MySQL database in Julia
本文介绍了如何在 Julia 中连接到 MySQL 数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是 Julia 的新手,过去几年一直使用 R,我正在努力完成我的第一个任务,即连接到我的 AWS MySQL 数据库.
I am new to Julia having used R for the last few years and I am struggling with my first task which is connecting to my AWS MySQL database.
我学习了许多在线教程,但无论我做什么,我都会收到相同的信息.
I have followed many online tutorials but I get the same message no matter what I do.
所有东西都是昨天安装的,所以应该都是当前版本.
Everything was installed yesterday so it should all be the current version.
julia-version = 版本 1.5.2
julia-version = Version 1.5.2
代码如下:
Pkg.add(PackageSpec(url="https://github.com/JuliaComputing/MySQL.jl"))
Pkg.add(PackageSpec(url="https://github.com/JuliaDB/DBI.jl"))
using MySQL
con = MySQL.connect("ec2blah.eu-west-2.compute.amazonaws.com", "name", "password", db = "database")
当我运行它时,我收到以下错误:
When I run this I get the following error:
UndefVarError: connect not defined
getproperty(::Module, ::Symbol) at Base.jl:26
top-level scope at data_prep.jl:18
谢谢
推荐答案
根据 文档,你可能应该这样做:
As per the documentation, you should probably do something like this:
using Pkg
Pkg.add("MySQL") # No need for a full PackageSpec here
Pkg.add("DBInterface")
using MySQL
using DBInterface
conn = DBInterface.connect(MySQL.Connection, "ec2blah.eu-west-2.compute.amazonaws.com",
"name", "password", db = "database")
这篇关于如何在 Julia 中连接到 MySQL 数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文