import sqlite3

database = 'instance/sqlite.db' # this is location of database

def schema():
    
    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL queries
    cursor = conn.cursor()
    
    # Fetch results of Schema
    results = cursor.execute("PRAGMA table_info('Players')").fetchall()

    # Print the results
    for row in results:
        print(row)

    # Close the database connection
    conn.close()
    
schema()
(0, 'id', 'INTEGER', 1, None, 1)
(1, '_name', 'VARCHAR(255)', 1, None, 0)
(2, '_uid', 'VARCHAR(255)', 1, None, 0)
(3, '_position', 'VARCHAR(255)', 1, None, 0)
(4, '_team', 'VARCHAR(255)', 1, None, 0)
(5, '_number', 'INTEGER', 0, None, 0)
import sqlite3

def create():
    _name = input("Enter your player here: ")
    _uid = input("Enter their profile name: ")
    _position = input("What position do they play? ")
    _team = input("Which team did they play for? ")
    _number = input("What is their jersey number? ")
    
    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL commands
    cursor = conn.cursor()

    try:
        # Execute an SQL command to insert data into a table
        cursor.execute("INSERT INTO Players (_name, _uid, _position, _team, _number) VALUES (?, ?, ?, ?, ?)", (_name, _uid, _position, _team, _number))
        
        # Commit the changes to the database
        conn.commit()
        print(f"A new user record {_uid} has been created")
                
    except sqlite3.Error as error:
        print("Error while executing the INSERT:", error)


    # Close the cursor and connection objects
    cursor.close()
    conn.close()
    
create()
A new user record shoheiohtani has been created
def read():
    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL queries
    cursor = conn.cursor()
    
    results = cursor.execute('SELECT * FROM Players').fetchall()

    # Print the results
    if len(results) == 0:
        print("Table is empty")
    else:
        for row in results:
            print(row)

    # Close the cursor and connection objects
    cursor.close()
    conn.close()
    
read()
(1, 'Mookie Betts', 'mookiebetts', 'Right Field', 'Los Angeles Dodgers', 50)
(2, 'Shohei Ohtani', 'shoheiohtani', 'Pitcher, Designated Hitter', 'Los Angeles Angels', 17)
import sqlite3

def update():
    uid = input("Enter user id to update")
    position = input("Enter new position here:")
    if len(position) < 2:
        message = "please re-enter your position."
    else:
        message = "successfully updated"

    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL commands
    cursor = conn.cursor()

    try:
        # Execute an SQL command to update data in a table
        cursor.execute("UPDATE Players SET _position = ? WHERE _uid = ?", (position, uid))
        if cursor.rowcount == 0:
            # The uid was not found in the table
            print(f"No uid {uid} was not found in the table")
        else:
            print(f"The row with user id {uid} the new position they play is {message}")
            conn.commit()
    except sqlite3.Error as error:
        print("Error while executing the UPDATE:", error)
        
    
    # Close the cursor and connection objects
    cursor.close()
    conn.close()
    
update()
The row with user id mookiebetts the new position they play is successfully updated
import sqlite3

def delete():
    uid = input("Enter user id to delete")

    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL commands
    cursor = conn.cursor()
    
    try:
        cursor.execute("DELETE FROM Players WHERE _uid = ?", (uid,))
        if cursor.rowcount == 0:
            # The uid was not found in the table
            print(f"No uid {uid} was not found in the table")
        else:
            # The uid was found in the table and the row was deleted
            print(f"The row with uid {uid} was successfully deleted")
        conn.commit()
    except sqlite3.Error as error:
        print("Error while executing the DELETE:", error)
        
    # Close the cursor and connection objects
    cursor.close()
    conn.close()
    
delete()
The row with uid shoheiohtani was successfully deleted
def read():
    # Connect to the database file
    conn = sqlite3.connect(database)

    # Create a cursor object to execute SQL queries
    cursor = conn.cursor()
    
    results = cursor.execute('SELECT * FROM Players').fetchall()

    # Print the results
    if len(results) == 0:
        print("Table is empty")
    else:
        for row in results:
            print(row)

    # Close the cursor and connection objects
    cursor.close()
    conn.close()
    
read()
(1, 'Mookie Betts', 'mookiebetts', 'Right Field', 'Los Angeles Dodgers', 50)