Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
nunogoncalves03 committed Dec 9, 2024
1 parent c89f411 commit 64f3872
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
12 changes: 4 additions & 8 deletions singlestoredb/magics/run_personal.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import time
from typing import Any

from IPython.core.interactiveshell import InteractiveShell
Expand Down Expand Up @@ -42,16 +41,13 @@ def run_personal(self, line: str, local_ns: Any = None) -> Any:
if not personal_file:
raise ValueError('No personal file specified.')

local_filename = (
f'{int(time.time() * 1_000_000)}_{personal_file}'.replace(' ', '_')
)
sql_command = f"DOWNLOAD PERSONAL FILE '{personal_file}' TO '{local_filename}'"
sql_command = f"DOWNLOAD PERSONAL FILE '{personal_file}' TO '{personal_file}'"

# Execute the SQL command
self.shell.run_line_magic('sql', sql_command)
# Run the downloaded file
self.shell.run_line_magic('run', local_filename)
self.shell.run_line_magic('run', "'" + personal_file + "'")

# Delete the local file after running it
if os.path.exists(local_filename):
os.remove(local_filename)
if os.path.exists(personal_file):
os.remove(personal_file)
10 changes: 4 additions & 6 deletions singlestoredb/magics/run_shared.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import os
import time
from typing import Any

from IPython.core.interactiveshell import InteractiveShell
Expand Down Expand Up @@ -42,14 +41,13 @@ def run_shared(self, line: str, local_ns: Any = None) -> Any:
if not shared_file:
raise ValueError('No personal file specified.')

local_filename = f'{int(time.time() * 1_000_000)}_{shared_file}'.replace(' ', '_')
sql_command = f"DOWNLOAD SHARED FILE '{shared_file}' TO '{local_filename}'"
sql_command = f"DOWNLOAD SHARED FILE '{shared_file}' TO '{shared_file}'"

# Execute the SQL command
self.shell.run_line_magic('sql', sql_command)
# Run the downloaded file
self.shell.run_line_magic('run', local_filename)
self.shell.run_line_magic('run', "'" + shared_file + "'")

# Delete the local file after running it
if os.path.exists(local_filename):
os.remove(local_filename)
if os.path.exists(shared_file):
os.remove(shared_file)

0 comments on commit 64f3872

Please sign in to comment.