File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 11import tempfile
22import shutil
33
4- from chdb import query
4+ from chdb import query , g_udf_path
55
66
7- class Session () :
7+ class Session :
88 """
99 Session will keep the state of query. All DDL and DML state will be kept in a dir.
1010 Dir path could be passed in as an argument. If not, a temporary dir will be created.
1111
1212 If path is not specified, the temporary dir will be deleted when the Session object is deleted.
1313 Otherwise path will be kept.
14-
15- Note: The default database is "_local" and the default engine is "Memory" which means all data
14+
15+ Note: The default database is "_local" and the default engine is "Memory" which means all data
1616 will be stored in memory. If you want to store data in disk, you should create another database.
1717 """
1818
@@ -28,8 +28,17 @@ def __del__(self):
2828 if self ._cleanup :
2929 self .cleanup ()
3030
31+ def __enter__ (self ):
32+ return self
33+
34+ def __exit__ (self , exc_type , exc_value , traceback ):
35+ self .cleanup ()
36+
3137 def cleanup (self ):
32- shutil .rmtree (self ._path )
38+ try :
39+ shutil .rmtree (self ._path )
40+ except :
41+ pass
3342
3443 def query (self , sql , fmt = "CSV" ):
3544 """
You can’t perform that action at this time.
0 commit comments