MCPcopy
hub / github.com/diffgram/diffgram / database_config

Method database_config

install.py:580–622  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

578 self.diffgram_version = version
579
580 def database_config(self):
581 local_database = bcolors.inputcolor(
582 'Do you want to use the local database? Y/N [Press Enter to use Local DB]: ')
583 local_database = local_database.lower()
584 if local_database == 'y' or local_database == '':
585 self.local_database = True
586 else:
587 self.local_database = False
588 valid = False
589 while not valid:
590
591 self.db_host = bcolors.inputcolor('Please provide the database host: ')
592 self.db_name = bcolors.inputcolor('Please provide the database name: ')
593 self.db_username = bcolors.inputcolor('Please provide the database username: ')
594 self.db_pass = bcolors.inputcolor('Please provide the database password: ')
595
596 # database_url = f"postgresql+psycopg2://{db_username}:{db_pass}@/{db_name}?host={db_host}"
597 database_url = f"postgresql+psycopg2://{self.db_username}:{self.db_pass}@{self.db_host}/{self.db_name}"
598
599 bcolors.printcolor('Testing DB Connection...', bcolors.WARNING)
600 try:
601 # Testing connection
602 engine = create_engine(database_url)
603 conn = engine.connect()
604 conn.close()
605 valid = True
606 self.database_url = database_url
607 bcolors.printcolor('✓ DB connection succesful!', bcolors.OKGREEN)
608 time.sleep(2)
609 except Exception as e:
610 bcolors.printcolor(
611 'Connection test failed: Please check that your DB URL has the correct values and try again.',
612 bcolors.FAIL)
613 bcolors.printcolor(f"Error data: {str(e)}", bcolors.FAIL)
614 valid = False
615
616 z_flag = bcolors.inputcolor(
617 'Do Add Z Flag to Postgres Mount? (Use only when using SELinux distros or similar) Y/N [Press Enter to Skip]: ')
618 z_flag = z_flag.lower()
619 if z_flag == 'y':
620 self.z_flag = True
621 else:
622 self.z_flag = False
623
624 def mailgun_config(self):
625 need_mailgun = bcolors.inputcolor(

Callers 1

installMethod · 0.95

Calls 3

inputcolorMethod · 0.80
printcolorMethod · 0.80
connectMethod · 0.45

Tested by

no test coverage detected