如何在Julia中连接到MySQL数据库 [英] How to connect to MySQL database in Julia

查看:94
本文介绍了如何在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆