-1

CSV to SQL server data ingestion using python getting issue in file path.

"/Users/raj/Desktop/csv_to_mssql/file_name.csv" could not be opened. Operating system error code 3(The system cannot find the path specified.).

Running this from local MacBook Pro, also if we need to run from any machine how can we set path.

  • 1
    Is SQL Server running in a Docker container? If so, you need to mount folders on the host so the container can see them (I wrote [an example here](https://sqlblog.org/2020/03/15/attaching-restoring-databases-inside-a-container) re: backups). Think of a container like a VM; it is isolated from the host on purpose. – Aaron Bertrand Jul 29 '23 at 16:32
  • It is on-premises server. – PRAVIN MASKE Jul 31 '23 at 15:06
  • 1
    Ok, but, where _is_ SQL Server running? What machine has `/Users/raj/`? It doesn't seem likely that SQL Server will be able to find that relative path in any case, but especially if it's on a different computer than the one where SQL Server is running. – Aaron Bertrand Jul 31 '23 at 15:21
  • Yes, /Users/raj/ is my machine local path, and SQL server we are connection using python and trying to run bulk insert command. – PRAVIN MASKE Aug 01 '23 at 05:40
  • Got it, Thank you so much for help. – PRAVIN MASKE Aug 01 '23 at 07:07

1 Answers1

1

You are using a relative path, that point out your user name (raj)... SQL Server is not you ! Avoid to use desktop or any user folder, and use a direct folder relative to a disk. As an example, create this folder :

"C:\xls_files\"

Then post your files into and everything will goes right !

SQLpro
  • 3,994
  • 1
  • 6
  • 14
  • I am running this from local mackbook DB eaver application to connect SQL server, but we are planning to automate using python script. if any help using the same it will be great. – PRAVIN MASKE Jul 31 '23 at 15:09