I am trying to load data from a very small dataframe into an MS SQL server database. This is documented in the ODBC.jl documentation, albeit as experimental. However it does not find the load function at all when I try to use it.
In any case, the present documentation definitely is not correct.
Note that I am using Julia 1.2-rc2 on Windows.
Partially answering my own question – it appears as if the ODBC.load! function is exported but not the ODBC.load ones. This does not work for me as I really need the append=true functionality.
Looks like I’ll have to use INSERT instead. Just considerably more work to set up.
Sorry for the slow response here; yes, I think the docs need updating, the current function is called
ODBC.load!, but as you noticed, it doesn’t really support appending (this is an odbc limitation, not a julia package limitation). So yes, doing your own INSERT statements is best for now. Note that ODBC does provide for statement “preparation” with parameterized values, which can then be executed multiple times; this is more efficient that just running
ODBC.query(conn, sql) or
ODBC.execute!(conn, sql) over and over. For preparing you call
ODBC.prepare(dsn::DSN, query::AbstractString), which returns a prepared
Statement object, then you can call
ODBC.execute!(statement::Statement, values) repeatedly, passing in values each time. So for an INSERT, doing:
stmt = ODBC.prepare(conn, "INSERT INTO tablename (col1, col2) VALUES(?, ?)")
for row in Tables.rows(table)
ODBC.execute!(stmt, (row.a, row.b))
Thank you, I came to the same conclusion as what you suggest here.