Exemplo n.º 1
0
def _update(sql, args):
    val = (args[1], args[0])
    mycursor.execute(sql, val)
    mydb.commit()
    print(mycursor.rowcount, "record updated")
    mycursor.execute("SELECT * FROM client")
    myresult = mycursor.fetchall()
    for x in myresult:
        print(x)
#!/usr/bin/python3
"""Deletes a client record in the database boli_assurance of SQL"""
import mysql.connector
import sys
from database_connect import mydb, mycursor
from tabulate import tabulate

sql = ("SELECT * FROM client WHERE id_client=%s")
args = sys.argv
val = (int(args[1]), )
mycursor.execute(sql, val)
myresult = mycursor.fetchall()
for x in myresult:
    print(
        tabulate(
            myresult,
            headers=['id_client', 'first_name', 'last_name', 'phone', 'email'],
            tablefmt='psql'))
#!/usr/bin/python3
""" Creates a vehicle record in the database boli_assurance of SQL"""
import mysql.connector
import sys
from database_connect import mydb, mycursor

sql = (
    "INSERT INTO vehicle (id_plate, value, date_assurance, time_asssurance, is_assured, id_employee, id_client) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)"
)
args = sys.argv
val = (int(args[1]), int(args[2]), args[3], int(args[4]), (args[5]),
       int(args[6]), int(args[7]))
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "record inserted")
mycursor.execute("SELECT * FROM vehicle")
myresult = mycursor.fetchall()
for x in myresult:
    print(x)
Exemplo n.º 4
0
#!/usr/bin/python3
"""Deletes an employee record in the database boli_assurance of SQL"""
import mysql.connector
import sys
from database_connect import mydb, mycursor
from tabulate import tabulate

sql = "SELECT * FROM employee"
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
    print(
        tabulate(
            myresult,
            headers=['id_employee', 'first_name', 'last_name', 'department'],
            tablefmt='psql'))
Exemplo n.º 5
0
#!/usr/bin/python3
"""Deletes a client record in the database boli_assurance of SQL"""
import mysql.connector
import sys
from database_connect import mydb, mycursor

sql = ("DELETE FROM client "
       "WHERE id_client=%s")
args = sys.argv
val = (int(args[1]),)
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "record deleted")
mycursor.execute("SELECT * FROM client")
myresult = mycursor.fetchall()
for x in myresult:
    print(x)
Exemplo n.º 6
0
#!/usr/bin/python3
""" Creates an employee record in the database boli_assurance of SQL"""
import mysql.connector
import sys
from database_connect import mydb, mycursor

sql = ("INSERT INTO employee (id_employee, first_name, last_name, department) "
       "VALUES (%s, %s, %s, %s)")
args = sys.argv
val = (int(args[1]), args[2], args[3], args[4])
mycursor.execute(sql, val)
mydb.commit()
print(mycursor.rowcount, "record inserted.")
mycursor.execute("SELECT * FROM employee")
myresult = mycursor.fetchall()
for x in myresult:
    print(x)