@@ -69,8 +69,12 @@ def _display_with_csv_download(self, df):
6969
7070 :param df: The DataFrame to display and make downloadable.
7171 """
72+ import IPython .display
73+
7274 try :
7375 # Generate CSV data
76+ import io
77+ import base64
7478 csv_buffer = io .StringIO ()
7579 df .to_csv (csv_buffer , index = False )
7680 csv_data = csv_buffer .getvalue ()
@@ -82,7 +86,7 @@ def _display_with_csv_download(self, df):
8286 download_link = f'data:text/csv;base64,{ csv_base64 } '
8387
8488 # Display the DataFrame first
85- display (df )
89+ IPython . display . display (df )
8690
8791 # Create and display the download button
8892 download_html = f'''
@@ -95,15 +99,15 @@ def _display_with_csv_download(self, df):
9599 </a>
96100 </div>
97101 '''
98- display ( HTML (download_html ))
102+ IPython . display . display ( IPython . display . HTML (download_html ))
99103
100104 except Exception as e :
101105 # If CSV generation fails, just display the DataFrame normally
102- display (df )
106+ IPython . display . display (df )
103107 print (f"Error generating CSV download: { e } " )
104-
108+
105109def load_ipython_extension (ipython ):
106110 """Load the server magic in IPython."""
107111 # Create an instance of the magic class and register it
108112 magic_instance = StackqlServerMagic (ipython )
109- ipython .register_magics (magic_instance )
113+ ipython .register_magics (magic_instance )
0 commit comments