Пример #1
0
def menu():
    os.system("cls")
    print(menu_str)
    a = input("Enter your choice: ")
    if a=="1":
        connect.connect_db()
    elif a=="2":
        connect.close_db()
    elif a=="3":
        connect.create_table()
    elif a=="4":
        connect.delete_table()
    elif a=="5":
        connect.get_rows()
    elif a=="6":
        connect.insert_row()
    elif a=="7":
        connect.delete_row()
    elif a=="8":
        connect.update_row()
    elif a=="9":
        connect.show_tables()
    elif a=="10":
        print("Thank you for using Postgres controller !!")
        time.sleep(1)
        sys.exit()
    else:
        print("Enter vaild choice")
        time.sleep(1)
        menu()
Пример #2
0
    def register(self):
        """ this function allows the user to register"""

        self.username = input('please enter your prefered username : '******'Please your email : '
            )  # Collect further information from the user email,phone and password.
            self.phone = input('please enter phone number : ')
            self.password = input('please enter password : ')

            try:  #Try to create and populate a table if it does not exist in the database

                connect.create_table()  #create the table in the database
                print(f"Created Table {connect.table_name}.")
                connect.add_user(
                    self)  #Populate the table with the user details

            except:  #populate the table in the database if it already exists

                connect.add(self)
                print(f"Table {connect.table_name} Exists .!!")
        else:  #Username already exists
            print("\nUsername already exists please try another !!!\n")
            self.register(
            )  #Call the registration process again to enter a new username
Пример #3
0
 def __init__(self):
     """Init method."""
     self.connection = create_connection()
     self.cursor = self.connection.cursor()
     self.table_name = input("Enter table name: ")
     self.table_tuple = self.table_columns()
     create_table(self.cursor, self.connection, self.table_name,
                  *self.table_tuple)
     self.user_info = self.user_info(*self.table_tuple)
     insert_data(self.cursor, self.connection, self.table_name,
                 *self.user_info)
     permission = input("Do you want to update a table(y/n): ")
     if permission == 'y':
         self.update_params = self.update_params()
         update_table(self.cursor, self.connection, self.table_name,
                      **self.update_params)
     else:
         pass
     permission = input("Do you want to drop a table(y/n): ")
     while permission == 'y':
         if permission == 'y':
             table_name = input("Enter the table name")
             drop_table(self.cursor, self.connection, table_name)
             permission = input("Do you want to drop a table(y/n): ")
         else:
             break
     self.connection.close()
Пример #4
0
    def create_note(self):

        title = input('Please enter Title : ')
        body = input('Body of note : ')
        note = Note(title, body)
        formatted_sql = [self.username, note.title, note.body]
        connect.create_table()
        connect.add(formatted_sql)