Skip to content
Advertisement

Tag: mysql

Python flask-sqlalchemy: Do I have to commit session after a query?

I am writing an app in python flask-sqlalchemy with MySQL DB (https://flask-sqlalchemy.palletsprojects.com/en/2.x/) and I am wondering if I have to make “db.session.commit() or db.session.rollback()” after GET call, which only query DB . For example: Answer orders = Order.query.all() is a SELECT query that could be extended to include additional filters (WHERE etc.). It doesn’t alter the database, it simply reads

Python Database that stays with the program

So mysql works great when you log into your mysql database program on that device but what if you want to move the program to another device, the connected databases wont work… Is there anyway to have the database somehow within the python file, so that when I move it to other devices it will act the same…Thank you! Answer

Import Data from .csv file into mysql using python

I am trying to import data from two columns of a .csv file (time hh:mm, float). I created a database and a table in mysql. If I run the program with executemany(), result is the following: [’01:00′, ‘1’] ‘-1 was inserted.’ and after this I do get the error code: Not all parameters were used again. When I try the

CSV data to MySQL table

I am trying to insert rows from a csv file into a MySQL table. I tried this code Nb: tab is a table with two columns name (varchar 20) and nb_cases (double) I get this error: DataError: (1265, “Data truncated for column ‘nb_cases’ at row 1”) Answer your number doesn’t fit it must be 983.469 with a point not a

Django 3.x error: ‘mysql.connector.django’ isn’t an available database backend

Having recently upgraded a Django project from 2.x to 3.x, I noticed that the mysql.connector.django backend (from mysql-connector-python) no longer works. The last version of Django that it works with is 2.2.11. It breaks with 3.0. I am using mysql-connector-python==8.0.19. When running manage.py runserver, the following error occurs: I am aware that this is not an official Django backend but

Advertisement