I created a a method in pythin so that user could login as a user or as an admin but the program is not working as I expected it to be, I am posting the whole program, but mainly the error is coming in login method as I am not able to create a proper logic required for the method.
Tag: mysql
How do I save scraped data to a MySQL database?
I have a python script that scrapes data from a job website. I want to save these scraped data to MySQL database but after writing the code, it connects to the database. Now after connecting, it doesn’t create table and as result couldn’t insert those data into the table. Please i need my code to store these scraped data to
SQLAlchemy / mysql – How to insert data without calculated (computed) columns
I have a calculated (computed) column in a table and would like to insert rows with the calculated column not specified with SQLAlchemy. However, the SQL query for insert generated by SQLAlchemy includes the calculated column. Is there a way not to specify a column in this case? Please refer to the following. Answer It looks like mysql accepts “DEFAULT”
SQL optimization to increase batch insert using Scrapy
In my previous post, I asked how I can record items in bulk using scrapy. The topic is here: Buffered items and bulk insert to Mysql using scrapy With the help of @Alexander, I can keep 1000 items in cache. However, my problem here is that the items in the cache are recording one by one while they are being
How to put db name into query using %s
I have a following sql query: The tableA is in db-jablonec so I need to call db-jablonec.tableA. I use this method in Python: I call it like this: But I got an error MySQLdb.ProgrammingError: (1146, “Table ”db-jablonec’.tableA’ doesn’t exist”) Obviously, I want to call ‘db-jablonec.tableA’ not ”db-jablonec’.tableA’. How can I fix it please? Answer It is passing %s as its
Insert error in a Mysql query Flask web app
My app.py code : This is the error I get : I am using python 3.10.2 and flask 2.2.2 in my virtual environment. And I am using Visual Studio IDE. It seems like I am doing something wrong in the MYSQL query. can you guys tell me what am i doing wrong here. Answer You are missing a closing bracket
Facing problem updating a column of a table, while the id and alias column remains same – sqlalchemy
Hi my table named ‘total’ looks like this, If I want to insert a new row with a new alias lets say alias = ‘lion’ and status = ‘gold’ it should create a new id and the table should look like this But if I keep the alias same as ‘lion’ and status = ‘silver’ it should just update the
INSERT table names using SELECT statement in MySQL
In MySQL, I know I can list the tables in a database with: But I want to insert a table name into a specified table, for example: But when I execute the above statement, the dataset_names table does not get updated. I created the master table using: Here is the python code. Answer Here the order on insert values and
Why is no error showing up when inserting a name that is not in the table sql/python
The problem that I am refering to is that if you insert something random in the USER_INP variable that is not in the database, it doesn’t show an error like THIS DOES NOT EXIST IN THE TABLE or something like that. What I want to achieve is when the user inserts something random in the USER_INP variable, the last message
How to store CSV file in database?
There is a output file from Python Pandas with a lot of columns with headers. I need to be able handle this file by script and get CSV files in different columns positions. For example, initial file has columns As variation I need to get it in different sequence: I wonder what is the best way to store this file