File tree 1 file changed +24
-0
lines changed
1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -502,6 +502,30 @@ def __init__(
502
502
503
503
redshift_native_auth : bool = False
504
504
505
+ if application_name is None or application_name == "" :
506
+
507
+ def get_calling_module () -> str :
508
+ import inspect
509
+
510
+ module_name : str = ""
511
+ stack : typing .List [inspect .FrameInfo ] = inspect .stack ()
512
+ try :
513
+ # get_calling_module -> init -> connect -> init -> calling module
514
+ start : int = min (4 , len (stack ) - 1 )
515
+ parent = stack [start ][0 ]
516
+ calling_module = inspect .getmodule (parent )
517
+
518
+ if calling_module :
519
+ module_name = calling_module .__name__
520
+ except :
521
+ pass
522
+ finally :
523
+ del parent
524
+ del stack
525
+
526
+ return module_name
527
+
528
+ application_name = get_calling_module ()
505
529
init_params : typing .Dict [str , typing .Optional [typing .Union [str , bytes ]]] = {
506
530
"user" : "" ,
507
531
"database" : database ,
You can’t perform that action at this time.
0 commit comments