O
O
Old_TyT2021-08-07 06:51:16
MySQL
Old_TyT, 2021-08-07 06:51:16

Why isn't MySQL recording?

I have code:

from mysql.connector import MySQLConnection, Error

class mysqlighter:
    def __init__(self, db_conf):
        self.conn = MySQLConnection(**db_conf)
        self.cursor = self.conn.cursor()
    
    def add_coin(self, coinsID, coins_symbol, coins_name):
        """Добавляем список коинов"""
        with self.conn:
            query = """INSERT INTO coinTables(id,symbol,name)
                VALUES(%s,%s,%s)"""
            args = (coinsID, coins_symbol, coins_name)
            print(self)
            print(self.cursor)
            try:
                self.cursor.execute(query, args)
            except Error as error:
                print(error)
        
    def coin_Tables(self):
        with self.conn:
            self.cursor.execute("DROP TABLE coinTables")
            create_table = """
            CREATE TABLE coinTables (
            id VARCHAR(255) NULL,
            symbol VARCHAR(255) NULL,
            name VARCHAR(255) NULL);
            """
            self.cursor.execute(create_table)

The coin_Tables function works well, but the add_coin function throws an error
2055: Lost connection to MySQL server at 'localhost:3306', system error: 9 Bad file descriptor

What is it and how to fix it?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question