-
Notifications
You must be signed in to change notification settings - Fork 38
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
Pooled Connections #140
Comments
Hey @mcmcgrath13! Thanks for opening this issue. It's funny because I've definitely been thinking about this over the last little while.
I'd love to see efforts here and am happy to chat on slack or in this issue about design ideas; just let me know what you're thinking! |
I'm going to start playing around w/ prototyping a generic ConnectionPooling.jl package. |
might be useful: DataFrames, MySQL, Dates
# ]add [email protected]
addslashes(x) = x
function addslashes(x::String)
x = replace(x,r"\\+(['\"\\])"=>s"\1")
x = replace(x,r"(['\"\\])"=>s"\\\1")
end
addslashes(x::T) where T <: Real = x
addslashes(x::Array) = json(x)
addslashes(x::DateTime) = Dates.format(x,"yyyy-mm-dd HH:MM:SS")
MYSQL_NUM_CONNECTIONS = 10
# Mysql连接
function mysql_init()
mysql_conn = MySQL.DBInterface.connect(MySQL.Connection, serv.address, serv.user, serv.pass; db=serv.db, port=serv.port, reconnect=true)
MySQL.DBInterface.execute(mysql_conn,"set names utf8")
mysql_conn
end
mysql_conn_pool = [ mysql_init() for i in 1:MYSQL_NUM_CONNECTIONS ]
mysql_conn = mysql_conn_pool[1]
function mysql_query(sql::String)
tmp_conn = mysql_conn_pool[rand(1:MYSQL_NUM_CONNECTIONS)]
try
MySQL.DBInterface.execute(tmp_conn,sql) |> DataFrame
catch e
println()
@show tmp_conn
@show e
@warn sql
return nothing
end
end
|
I don't think you want pooling to be done randomly at the query level. Because things like |
@quinnj I'm thinking about building out some infrastructure for pooling connections (similar to the js mysql package). A few questions:
The text was updated successfully, but these errors were encountered: