Category : mysql-connector

I’m trying to use searchedInput outside my if statement so I could use the variable inside my query. but it gives me an error of UnboundLocalError: local variable ‘searchedInput’ referenced before assignment @app.route(‘/ML’, methods=[‘GET’, ‘POST’]) def index(): if request.method == "POST": request_data = json.loads(request.data) searchData = (request_data[‘content’]) searchedInput = jsonify(searchData) return searchedInput mycursor = mydb.cursor(dictionary=True) ..

Read more

import mysql.connector mydb = mysql.connector.connect( host="10.0.72.17", user="admin", passwd="1qaz!QAZ", database="test" ) mycursor = mydb.cursor() sql = "INSERT INTO biage(kompaniis_saxeli) VALUES (%s)" val = (‘bane’) mycursor.execute(sql, val) mycursor = mydb.cursor() mydb.commit() This is my python code , and i create column kompaniis_saxeli varchar(225) but when i try to run this code there is error raise ValueError("Could not ..

Read more

enter code heresql= "INSERT INTO d_table VALUES(%s, %s, %s, %s, %s)" enter code herecursor.execute(sql,(z, lname1, namt1, side1, ndate)) enter code heremydb.commit() Hello, I have multiple tables in MYSQL (workbench) and i want to insert values into table selected by the user, d_table variable is text variable that contains the table name selected by user but ..

Read more

I have installed MySQL Server 8.0.27 through https://dev.mysql.com/downloads/mysql/, arm version ofcourse. I also installed MySQL WorkBench 8.0.27. At the moment, I still can’t access my SQL server through Terminal. Anyway, I then tried to access it through python jupyter notebook. Yesterday I could access and created several tables in SQL server. I could also see ..

Read more

i want to send my variable to MySQL database. But, i have a warning. This code was succesfull to upload. Code import mysql.connector try: connection = mysql.connector.connect(host=’localhost’, database=’mydb’, user=’root’, password=”) cursor = connection.cursor() username = 1111111 #example isian = "tryfile.pkl" #example, i want send string data print("Before updating a record ") sql_select_query = """select * ..

Read more

sql_df= final_df[[‘Label’,’customer_id’,’Keyword’,’updated_user’,’tags’]] cursor = conn.cursor() query = ("INSERT INTO keywords (Label, customer_id, Keyword, updated_by_user, ML_tags)" " VALUES (%s, %s, %s, %s, %s)" ) cursor.executemany(query, list(sql_df.to_records(index=False))) conn.commit() my sample record (‘Non-Brands’, ’12’, ‘local shops’, ‘ram’, ‘test’) i am trying to insert to cloud sql from dataframe When I try to run the script, I get the ..

Read more