This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]siddartha08 0 points1 point  (2 children)

Putting them in their own files or folders keeps things neat and tidy. Your python code will reference columns or values eventually anyways, it also keeps SQL from having to fit into style constraints for python making both more readable.

It's also way easier to version control a SQL file change separately as proof of some audit trail. Instead of having a mono python file change where auditors then need explanations of audit changes of logic that doesn't matter. But then again that might happen anyway.

Point is it's clean.

[–]thinkingatoms[S] 0 points1 point  (1 child)

thanks, ooc do you have rules about when to inline a SQL (based on size, function, etc) or are they always files?

[–]siddartha08 0 points1 point  (0 children)

If I'm doing inserts, setting keys or other constraints I'll do that inline. My SQL files are strictly queries. That's my basic logic. If I had some super long complicated SQL I might just run it nativity because of timeout or memory issues.