r/BusinessIntelligence • • Feb 25 '19

Automating File Loading Into SQL Server With Python And SQL - Part 1

https://www.youtube.com/watch?v=OnzBuzRX3FE
26 Upvotes

10 comments sorted by

0

u/[deleted] Feb 25 '19

[deleted]

5

u/nonkeymn Feb 25 '19

SQL Server agent is great! I have actually done something similar with SSIS where instead of insert statements the table kept track of which SSIS file belonged to what raw files. So as we got raw files in, we had a powershell script that was run by SQL Server agent that would track it and map it to the correct raw files to their corresponding SSIS packages. Then, it would run the SSIS packages.

I think depends on what you prefer. I have met people that down right hate SSIS because it feels limiting to them since they like programming. In the same way, I have met people that love SSIS because you can have SSI do a lot of the heavy lifting.

The only frustration I have with SSIS is how it freaks out at the smallest meta data changes. However, most ETL products do that.

2

u/sammersd Feb 26 '19

Cozyroc is an solution that allows for dynamic Metadata within ssis, as well as a ton others. Recommended.

1

u/nonkeymn Feb 26 '19

I will have to check that out.

1

u/emican Feb 26 '19

SSIS and codeless ETL tools are great for canned use cases and if the solution has to be heavily researched, python seems more efficient. I thought your video was interesting and like working with people that can do stuff like that because they are less likely to say 'It can't be done!' :)

My project was loading json docs and my loader would hash the schema, and compare to a table of schema hashes. If the schema has was brand new, the doc would be tested for expected data points/types, logged and loaded if tests passed. Manually inspecting for a one-off case vs new pattern was still necessary.

1

u/nonkeymn Feb 26 '19

SSIS does allow for some custom coding but even that has its limitations.

Yes, custom coding is great as long as you have some base infra. Having to building all tracking, dependency management and logging from the ground up can be very time consuming.

But I do love the flexibility it allows.

1

u/JFancke Feb 26 '19

I haven't had a chance to play too much with the recent Power Query (preview) integration into SSIS, but I'm hoping that this provides a better way to handle some metadata changes in the source.

0

u/[deleted] Feb 26 '19

[deleted]

1

u/nonkeymn Feb 26 '19

Yes! That makes sense as well. The biggest pain there is how many data flow tasks dow you have because it gets crazy with all the green arrows. But that's not really a big deal.

Of course all these systems work great when we are referring to csv, tsv or other delimited data sets.

F*** positional files for any ETL process. Unless you have some tips for that as well!

0

u/[deleted] Feb 26 '19

[deleted]

1

u/nonkeymn Feb 26 '19

Yes, exactly. I have done it in SSIS and Oracle control files, and it always sucks... But that is what happens when you work with older companies.

1

u/Black_Magic100 Feb 25 '19

Is SQL server agent just like a bot that runs a task every X hours or whatever? Sorry I am not familiar with SSIS/ETL in the sense of actually applying it to real work since I'm still in college.

I just started looking into potential ways of inserting my API requests that I made in Python and have them insert into my SQL server. Having trouble formatting the JSON right now as this is all new to me and I have no mentor to help at work.

2

u/nonkeymn Feb 26 '19

Welcome to the rest of your technical career :). I mean, it depends on where you work. One job I had no mentor and made a lot of bad choices. The next job I had some amazing mentors. SQL Agent Sits on SQL Server and allows you to automate tasks on SQL server. It is similar to crontab but only on SQL server. So yes. SSIS is a tool that helps extract, transform and load (ETL) data from source to target locations.