<commit_before>from sql import SQLConnection
import pymssql


def dbPlaceBid(userType, itemId, alias, newBid):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor()

    cursor.callproc('uspNewBid', (itemId, alias,newBid,))
    con.commit()
    sqlCon.close(con)

def checkLogin(alias, password):
    result = False

    sqlCon = SQLConnection()
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('uspCheckLogin', (alias,password,))
    for row in cursor:
        if row['EXITO'] == 1:
            result = True

    sqlCon.close(con)
    return result

def dbNewListing(userType, alias,
    description, category, subCategory, listingEndDate, startingPrice):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)

    cursor.callproc('uspNewAuction', (alias, description, category,
        subCategory, listingEndDate,int(startingPrice),))
    con.commit()
    sqlCon.close(con)


def getUserType(alias):
    sqlCon = SQLConnection()
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('upsGetKindOfUser', (alias,))

    for row in cursor:
        if row['Exito'] == 0:
            sqlCon.close(con)
            return None
        elif row['Administrator'] == 1:
            sqlCon.close(con)
            return 'admin'
        elif row['Agent'] == 1:
            sqlCon.close(con)
            return 'agent'
        elif row['Participant'] == 1:
            sqlCon.close(con)
            return 'participant'


def getListingsByUser(user, userId, userType):
    if user == "----":
        user = None

    listings = []

    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    #get all listings
    cursor.callproc('uspViewSellerHistory', (user, userId,))

    for row in cursor:
        listings.append(row['Alias'])
    sqlCon.close(con)
    return listings

def getWinningListingsByUser(user, userId, userType):
    if user == "----":
        user = None

    listings = []

    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    #get all listings
    cursor.callproc('uspViewWonAuctionHistory', (user,userId,))
    for row in cursor:
        listings.append(row['Alias'])
    sqlCon.close(con)
    return listings

def dbNewAdmin(userType,name, lastName, alias,
    password,address,personalId):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('uspAddNewAdmin', (alias,password, name, lastName,address,personalId,))
    con.commit()
    sqlCon.close(con)

def dbNewAgent(userType,name, lastName, alias,
    password,address,personalId):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)

    cursor.callproc('uspAddNewAgent', (alias,password,
        name, lastName,address,personalId,))

    con.commit()
    sqlCon.close(con)

def dbAddPhones(userType,alias,phones):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    for phone in phones:
        if phone!="":
            cursor.callproc('uspAddPhoneNumber', (alias,phone,))
    con.commit()
    sqlCon.close(con)<commit_msg>NewCard Connection with db<commit_after>from sql import SQLConnection
import pymssql


def dbPlaceBid(userType, itemId, alias, newBid):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor()

    cursor.callproc('uspNewBid', (itemId, alias,newBid,))
    con.commit()
    sqlCon.close(con)

def checkLogin(alias, password):
    result = False

    sqlCon = SQLConnection()
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('uspCheckLogin', (alias,password,))
    for row in cursor:
        if row['EXITO'] == 1:
            result = True

    sqlCon.close(con)
    return result

def dbNewListing(userType, alias,
    description, category, subCategory, listingEndDate, startingPrice):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)

    cursor.callproc('uspNewAuction', (alias, description, category,
        subCategory, listingEndDate,int(startingPrice),))
    con.commit()
    sqlCon.close(con)


def getUserType(alias):
    sqlCon = SQLConnection()
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('upsGetKindOfUser', (alias,))

    for row in cursor:
        if row['Exito'] == 0:
            sqlCon.close(con)
            return None
        elif row['Administrator'] == 1:
            sqlCon.close(con)
            return 'admin'
        elif row['Agent'] == 1:
            sqlCon.close(con)
            return 'agent'
        elif row['Participant'] == 1:
            sqlCon.close(con)
            return 'participant'


def getListingsByUser(user, userId, userType):
    if user == "----":
        user = None

    listings = []

    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    #get all listings
    cursor.callproc('uspViewSellerHistory', (user, userId,))

    for row in cursor:
        listings.append(row['Alias'])
    sqlCon.close(con)
    return listings

def getWinningListingsByUser(user, userId, userType):
    if user == "----":
        user = None

    listings = []

    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    #get all listings
    cursor.callproc('uspViewWonAuctionHistory', (user,userId,))
    for row in cursor:
        listings.append(row['Alias'])
    sqlCon.close(con)
    return listings

def dbNewAdmin(userType,name, lastName, alias,
    password,address,personalId):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    cursor.callproc('uspAddNewAdmin', (alias,password, name, lastName,address,personalId,))
    con.commit()
    sqlCon.close(con)

def dbNewAgent(userType,name, lastName, alias,
    password,address,personalId):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)

    cursor.callproc('uspAddNewAgent', (alias,password,
        name, lastName,address,personalId,))

    con.commit()
    sqlCon.close(con)
    
def dbAddCard(userType,alias, cardNumber, securityCode,
    cardName, expirationDate):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)

    cursor.callproc('uspAddCard', (alias,securityCode,
        cardNumber, cardName,expirationDate,))
    con.commit()
    sqlCon.close(con)

def dbAddPhones(userType,alias,phones):
    sqlCon = SQLConnection(userType)
    con = sqlCon.connect()
    cursor = con.cursor(as_dict=True)
    for phone in phones:
        if phone!="":
            cursor.callproc('uspAddPhoneNumber', (alias,phone,))
    con.commit()
    sqlCon.close(con)
{'fraction_non_alphanumeric': 0.12440944881889764, 'fraction_numerical': 0.0014316392269148174, 'mean_word_length': 3.0949589683470107, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5959755', 'n_tokens_mistral': 2266, 'n_tokens_neox': 2199, 'n_words': 452}