Hello there im trying to execute a SQL query using Flask with mysqldatabase, the query returns as a JSON managed my JQuery on the front end. The goal is to use a search bar to find any matches with the data base. The query works just fine if I use just one “like” sentence, for example. But in the moment
Tag: mysql
Flask TypeError: ‘method’ object is not subscriptable
I am building a dictionary app with Flask where users can add new words, the code below is the app.py file, I am having issues with the POST request, the error I am receiving on my terminal is this: This code below is the app.py file here is my dashboard page or route: Answer get_json is the actual method, which,
Pending request on Django
I’m building a website using Django. I have the register and login sessions working, so any user can create an account and login. But now I want a situation whereby when someone creates an account, the account will be inactive and pending until the admin accepts the user. However, I haven’t implemented any code that does that before and I
mysql connector with python formating
I wrote a simple script that shows the user a letter and he has to write a human name that starts with the same letter, but I am having a problem automatically compensating for the column name using a variable… Is there a suggestion? How do I replace the column name with the variable let? The error: Answer You just
Loading CSV into dataframe results in all records becoming “NaN”
I’m new to python (and posting on SO), and I’m trying to use some code I wrote that worked in another similar context to import data from a file into a MySQL table. To do that, I need to convert it to a dataframe. In this particular instance I’m using Federal Election Comission data that is pipe-delimited (It’s the “Committee
Execute mysql commands in linux terminal using Python
I would like to automate the setup of a database and I would like to do it by using a python script to execute some commands in a linux terminal. But I cannot see any way of executing commands in the terminal after connection to mysql database. Below you can see a part of the script: This starts mysql, and
Django inspectdb omitted integer primary key
I have a legacy MySQL db, and I am trying to create Django models from it so I can use the legacy tables in my Django application. I ran inspectdb on the MySQL db and it seemed to import most fields correctly, but failed to import every single primary key and/or id field. Is this the expected behavior? I will
Convert a list to comma separated strings for sql IN operator
This seems very obvious use case and I am surprised I was not able to find any single working solution for this. I have a method which returns a list of usernames something similar to this: Now I want to use this variable to build a sql for IN operator, something similar to this: above line obviously fails due to
List index out of range for Python
I have a question regarding the following exercise: In this function, I print lastrecord.fetchall()[0][0] and quantity.get to make sure they are float. So the program prints in that case: 5.0 for lastrecord.fetchall and quantity.get Up to now, no problem, but when I try to us them up, it gives me an error of List Index Out Of Range, so program
How to format a mysql datetime yyyy-mm-dd to dd-mm-yyyy in Python?
My python code retrieves a datetime column from a mySql server database. I can print the datetime as it is stored on the server (ex. 2018-10-22, however I need to print it in a more readable way like 22-10-2018. Basically, row[0] holds datetime data as the code below. Thanks for any help. Answer If your time is a datetime object