def deleteProducts(id):
     sql = "delete from school where id=%s"
     value = (id, )
     Student.cursor.execute(sql, value)
     try:
         connection.commit()
         print(f"{Student.cursor.rowcount} tane kayıt silindi.")
     except mysql.connector.Error as err:
         print("hata: ", err)
     finally:
         connection.close()
         print("database kapatıldı")
 def updateProducts(id, name, surname):
     sql = "update school set name=%s,surname=%s where id=%s"
     value = (name, surname, id)
     Student.cursor.execute(sql, value)
     try:
         connection.commit()
         print(f"{Student.cursor.rowcount} tane kayıt güncellendi.")
     except mysql.connector.Error as err:
         print("hata: ", err)
     finally:
         connection.close()
         print("database kapatıldı")
 def saveStudents(students):
     sql = "INSERT INTO school(studentNumber,name,surname,birthday,gender) VALUES (%s,%s,%s,%s,%s)"
     values = (students)
     Student.cursor.executemany(sql, values)
     try:
         connection.commit()
         print(f"{Student.cursor.rowcount} tane kayıt eklendi.")
     except mysql.connector.Error as err:
         print("hata: ", err)
     finally:
         connection.close()
         print("database kapatıldı")
示例#4
0
def write_to_db(match, data):
    if match:
        try:
            with connection.cursor() as cursor:
                sql = """
                INSERT INTO `post_request`.`request` (`first_name`, `last_name`) VALUES (%s,%s)
                """
                # for x in request:
                cursor.execute(sql, (data['firstname'], data['lastname']))
            connection.commit()
        finally:
            connection.close()
示例#5
0
	def close(self):
		if self.__streamDump:
			self.__streamDump.close()

		connection.close(self)
示例#6
0
    def close(self):
        if self.__streamDump:
            self.__streamDump.close()

        connection.close(self)
示例#7
0
# install with python3 -m pip install PyMySQL
from connection import connection
from create import create_db
from insert import insert_jovem, insert_carteira, insert_inep, insert_enem

create_db(connection)
insert_jovem(connection, "10097142441",
             "Otacilio Saraiva Maia Neto", "14/12/1996")
insert_carteira(connection, "10097142441", "Dona Faker",
                "Seu Sumido", "Cesinha School", "*****@*****.**")
insert_inep(connection, "10097142441", "1218721872128", "2017")
#                      CPF  MASCULINO  Br Pub Single Rico 20 urbana 1tv 3pcs no_car 1   2  net   tv  po emprega banh trablh
insert_enem(connection, "10097142441", "1218721872128", "2017", "M", 1, 1,
            0, "Q", 20, "B", "A", "C", "D", "A", "B", "A", "A", "D", "C", "B", "A")
# Guardar dados em memoria pra inserir de vez

connection.close()