<reponame>itsayusharya/passwordmanger
import sqlite3
import random


class Password:
    """"Password Generator"""

    def __init__(self):
        """constructor"""
        lower = "abcdefghijklmnopqrstuvwxyz"
        upper = lower.upper()
        numbers = "1234567890"
        symbols = "!@#$%^&*()_+<>?"

        # Creates one single pool of characters
        self.char_pool = lower+upper+numbers+symbols

    def generate(self):
        """Generates Strong Password"""
        pass_len = random.randint(8, 32)  # Randomly select password length
        char_list = [random.choice(self.char_pool)
                     for char in range(pass_len)]  # Creates characters list

        # Creates password by joining individual index from char_list
        self.password = "".join(char_list)
        return self.password

    def passdb(self):
        self.con = sqlite3.connect("pass.db")
        self.cur = self.con.cursor()
        self.cur.execute(
            """CREATE TABLE IF NOT EXISTS passwords(username, password)""")

        print("Enter Username: ")
        username = input()
        password = self.generate()
        print(f"Password generated for username '{username}': {password}")

        with self.con:
            self.cur.execute("INSERT INTO passwords VALUES(:user,:pass)",
                             {'user': username, 'pass': password})

            self.con.commit()
        self.con.execute(
            "SELECT * FROM passwords")

        print(self.cur.fetchall())


Password().passdb()

import sqlite3
import random


class Password:
    """"Password Generator"""

    def __init__(self):
        """constructor"""
        lower = "abcdefghijklmnopqrstuvwxyz"
        upper = lower.upper()
        numbers = "1234567890"
        symbols = "!@#$%^&*()_+<>?"

        # Creates one single pool of characters
        self.char_pool = lower+upper+numbers+symbols

    def generate(self):
        """Generates Strong Password"""
        pass_len = random.randint(8, 32)  # Randomly select password length
        char_list = [random.choice(self.char_pool)
                     for char in range(pass_len)]  # Creates characters list

        # Creates password by joining individual index from char_list
        self.password = "".join(char_list)
        return self.password

    def passdb(self):
        self.con = sqlite3.connect("pass.db")
        self.cur = self.con.cursor()
        self.cur.execute(
            """CREATE TABLE IF NOT EXISTS passwords(username, password)""")

        print("Enter Username: ")
        username = input()
        password = self.generate()
        print(f"Password generated for username '{username}': {password}")

        with self.con:
            self.cur.execute("INSERT INTO passwords VALUES(:user,:pass)",
                             {'user': username, 'pass': password})

            self.con.commit()
        self.con.execute(
            "SELECT * FROM passwords")

        print(self.cur.fetchall())


Password().passdb()
"Password Generator constructor #$%^&*()_+<>?" # Creates one single pool of characters Generates Strong Password # Randomly select password length # Creates characters list # Creates password by joining individual index from char_list CREATE TABLE IF NOT EXISTS passwords(username, password)