-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MySQL test #8
base: dev
Are you sure you want to change the base?
MySQL test #8
Changes from 7 commits
526ca48
9ea3bd1
ccb0995
9f01623
8c81230
5629e7e
163e622
954d9f7
d5a65ac
1612cf6
48a66d9
faa502a
82a41cc
8de99b7
a8a00d1
ae2f676
50a4dbb
e7e09bd
6952fa6
13fcf78
2c3aa6d
5fdeff3
bfc7ed2
6138c7a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,23 @@ | ||
using Documenter, Example | ||
|
||
makedocs(modules = [Example], sitename = "Example.jl") | ||
makedocs(; | ||
modules = [DBConnector], | ||
authors = "Jacob Zelko (aka TheCedarPrince) <[email protected]> and Fareeda", | ||
repo = "https://github.com/JuliaDatabases/DBConnector.jl", | ||
sitename = "DBConnector.jl", | ||
format = Documenter.HTML(; | ||
prettyurls = get(ENV, "CI", "false") == "true", | ||
canonical = "https://github.com/JuliaDatabases/DBConnector.jl" | ||
edit_link = "dev", | ||
footer = "Created by [Jacob Zelko](https://jacobzelko.com) & [Georgia Tech Research Institute](https://www.gtri.gatech.edu). [License](https://github.com/JuliaHealth/OMOPCDMCohortCreator.jl/blob/main/LICENSE)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can remove the footer variable here. |
||
), | ||
pages = [ | ||
"Home" => "index.md", | ||
"Functions" => "Functions.md" | ||
], | ||
|
||
deploydocs(repo = "github.com/quinnj/Example.jl.git", push_preview = true) | ||
) | ||
deploydocs(repo = "github.com/quinnj/Example.jl.git", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh could you update this to the repo URL as shown above? Don't forget the |
||
push_preview = true, | ||
devbranch = "main", | ||
) |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am holding off on reviewing this documentation until we chat about tests and further about the API! |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Functions | ||
|
||
```@contents | ||
Pages = ["Functions.md"] | ||
``` | ||
|
||
## _dbconnect() | ||
|
||
This Function is dedicated to expand the range of connection between The [OMOPCDMCohortCreator](https://github.com/JuliaHealth/OMOPCDMCohortCreator.jl) with databases. | ||
Databases exist are SQLite, MySQL, PostgreSQL. | ||
In the upcoming sections, we will learn about these tools. | ||
|
||
### SQLite | ||
|
||
Assuming your data exists on a SQLite database and you want to connect it to the OMOPCDMCohortCreator. | ||
|
||
calling the function | ||
|
||
``` _dbconnect(SQLite.Connection,"path/to/database.db") ``` | ||
|
||
|
||
|
||
### MySQL | ||
|
||
Assuming your data exists on a MySQL database and you want to connect it to the OMOPCDMCohortCreator. | ||
|
||
Make sure that the server is running and using `MySQL.API`: | ||
|
||
``` systemctl status mysql ``` | ||
|
||
calling the function | ||
|
||
``` _dbconnect(MySQL.Connection, "host_name", "username", "password"; db = "database_name" , port = port_num, unix_socket = "unix_socket_data_path" ) ``` | ||
|
||
those parameters must exist: | ||
|
||
- host_name : if you are working on same machine server it will be "local host" | ||
|
||
- username | ||
- password | ||
|
||
Can be known by openning all the `.cnf` files until you find them. I wasn't lucky and opened around 5 till I found the right one. Don't give up! | ||
|
||
If unix_socket is not inserted, the default one is given | ||
|
||
|
||
|
||
For any struggles MySQL related, [Read this](https://dev.mysql.com/doc/refman/8.0/en/starting-server.html) | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ Example Julia package repo. | |
```@autodocs | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fareeda, could you open an issue about needing to update the home page of DBConnector.jl's documentation? Thanks! |
||
Modules = [Example] | ||
``` | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
function _dbconnect(conn_obj::Type{MySQL.Connection}, kwargs) | ||
function _dbconnect(conn_obj::Type{MySQL.Connection}, host::String, user::String, password::String; db::String="", port::Integer=3306, unix_socket::Union{Nothing,String}=nothing, client_flag=API.CLIENT_MULTI_STATEMENTS, opts = Dict()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I am not too sure on this layout here; I think it would be better to have the second argument actually only be a string that is passed to the connection. Let's discuss during our check-in. |
||
|
||
return DBInterface.connect(conn_obj; kwargs...) | ||
if unix_socket == nothing | ||
unix_socket = API.MYSQL_DEFAULT_SOCKET | ||
end | ||
|
||
return DBInterface.connect(conn_obj,host, user, password, db=db, port=port, unix_socket=unix_socket, client_flag=client_flag, opts=opts ) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function _dbconnect(connector::Type{SQLite.DB}; file_path) | ||
function _dbconnect(connector::Type{SQLite.DB}, file_path::String) | ||
|
||
return connector(file_path.second) | ||
return connector(file_path) | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
using Test, Example | ||
using MySQL,SQLite, MySQL.API | ||
|
||
@test hello("Julia") == "Hello, Julia" | ||
@test domath(2.0) ≈ 7.0 | ||
|
||
@testset "_dbconnect function for SQLite" begin | ||
|
||
conn= _dbconnect(SQLite.DB, "DBConnector.jl/test/data/database.db") | ||
@test @isdefined conn | ||
|
||
end | ||
|
||
@testset "_dbconnect function for MySQL" begin | ||
|
||
conn = _dbconnect(MySQL.Connection, "localhost", "debian-sys-maint","HGGsOLypO2LVqq1v", db="mydatabase", port=3306, unix_socket="/var/run/mysqld/mysqld.sock") | ||
@test typeof(conn) == MySQL.Connection | ||
@test isopen(conn) | ||
close(conn) | ||
|
||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very great that this is working! Like you said, we'll need to determine how to run these tests somewhere else. I'd like to somehow get this connection made to the GSoC Server for testing over the summer while somehow maintaining secrecy for our server credentials. Let's talk about this at our weekly check-in! |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to also add your last name and email too! :D