1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] How access SQL database with Python code?

Discussão em 'Python' iniciado por Stack, Outubro 7, 2024 às 12:52.

  1. Stack

    Stack Membro Participativo

    I'm writing a Python code that is connecting to an SQL database called 'travel_db' to add a line in a table called 'users'.

    Somehow, when I run a test, I keep receiving the same error:

    Error: 1146 (42S02): Table 'travel_db.travel_db' doesn't exist


    The function that is calling for the travel_db database is as follows:

    def add_user_logic(self, user):
    sql = """
    insert into travel_db.users(f_name,
    l_name,
    email,
    password_num,
    role_id)
    values (%s,%s,%s,%s,%s)
    """
    insert_row = self.dal.insert_dal(sql,(user.f_name,
    user.l_name,
    user.email,
    user.password_num,
    user.role_id,))
    return insert_row


    I was expecting the be able to access the travel_db database.

    Continue reading...

Compartilhe esta Página