r/DatabaseHelp • • Sep 17 '15

On uploading CSV data to SQL

After searching around on the subject, i found everyone uses the local filesystem and does a bulk insert. As much as i would like to jump on that bandwagon, at my work we don't have access to the local filesystem; only the database. Am i missing something that allows uploads into the filesystem via SQL? or does everyone else also have an FTP set up?

2 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/marcus13345 Sep 17 '15

unfortunately that wouldn't be an option as im a subcontractor and have no idea where the DB will be deployed. my boss has told me to just refernce one connection string for the database so that it can be changed at will. it likely in the end wont be on the same network. i did let him know about the problem today though, hopefully he gets back to me with either an ftp/smb solution or the okay to just do row by row injection... my hope was that there was a way to pass a large blob into a stored procedure and parse through it database side, inserting row by row then.

1

u/jeffrey_f Sep 17 '15

You can create a python script to do it. I'm not an expert, but I could probably cobble together enough pertinent code (google is my friend) to create a script to connect to the DB, read the CSV and do sql inserts........

At some point, someone will need to nail down where the production db will live (IP or HostName) so that the imports can happen automagically......

You can create a "config" file for your script that will read in the server name, user, password too so you can just change the details for production time.