seamusabshere / upsert

Upsert on MySQL, PostgreSQL, and SQLite3. Transparently creates functions (UDF) for MySQL and PostgreSQL; on SQLite3, uses INSERT OR IGNORE.
MIT License
652 stars 77 forks source link

Support ODBC driver #31

Open DaveSanders opened 10 years ago

DaveSanders commented 10 years ago

I can't say I'm surprised, but upsert doesn't suport ODBC::Database driver. Just so happens for this one client I need to upsert to a ODBC (MSSQL) database.

If someone were to give me a clue where to start, I might be able to help here. But I haven't had a chance to go dig through the code to figure out whats needed.

I suspect its not an itch that many people need to scratch. But I figured I'd log it.

seamusabshere commented 10 years ago

hey @DaveSanders, a good place to start is to provide a working example of upsert in MSSQL.

  1. (best) do it with SQL MERGE since MSSQL seems to support that
  2. (better) write a database function that takes the same inputs as the postgres upsert function and the mysql upsert function
  3. (worst) do it with something like INSERT OR IGNORE + UPDATE as in the sqlite3 upsert function

if you provide the SQL and a narrative of how it works, I can help wrap it in Ruby to be part of this gem.

DaveSanders commented 10 years ago

Excellent. We'll figure it out and get back to you.

DaveSanders commented 10 years ago

Ok, here's a working merge example in MSSQL: https://gist.github.com/DaveSanders/8721734

seamusabshere commented 10 years ago

hey @pnomolos , would you have time to create the requisite files

  1. lib/upsert/column_definition/mssql.rb
  2. lib/upsert/connection/ODBC_Database_MSSQL.rb (not sure what the exact class name is)
  3. lib/upsert/merge_function/ODBC_Database_MSSQL.rb (ditto)
  4. lib/upsert/merge_function/mssql.rb

then perhaps @DaveSanders can help fill them out?

(sorry for huge delay in responding, I've been swamped at work)

pnomolos commented 10 years ago

Hey @seamusabshere and @DaveSanders sorry for the big delay - do you still need me to take a look at this?

seamusabshere commented 10 years ago

hey @pnomolos that would be great!

seamusabshere commented 10 years ago

hi @pnomolos it's me again ;)

given my comment above listing files needing to get created, would you have time to kickstart this?

pnomolos commented 10 years ago

I'll see what I can do to get this done - or at least started - over the weekend :)