10

I am learning Python / Flask. Now I am at the point where I am learning Flask with MySQL Database. I read lots of posts about using Flask with databases and most of them suggest to use SQLAlchemy. I tried to read about SQLAlchemy, but I didn't like that because I prefer building and executing SQL queries and creating tables in the database only. Is there any way that I can take full benefit of using Flask with MySQL Database without SQLAlchemy?

Please suggest.

MarredCheese
  • 17,541
  • 8
  • 92
  • 91
user20072008
  • 359
  • 7
  • 23
  • 4
    Great question. I love SQL and lean on the side of those who think that [ORM is an anti-pattern](http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern). I've been looking for a way to use a framework for user management and form-generation without "giving away the keys to the database". – zx81 Jul 17 '15 at 03:32

1 Answers1

4

You don't have to use SQLAlchemy, no. You just have to connect to the database in Flask and execute your queries manually.

This question is about how to connect to MySQL with Python, and the official docs go over creating a site with a SQLite database. Modify the examples provided there with your MySQL connection.

Community
  • 1
  • 1
Celeo
  • 5,583
  • 8
  • 39
  • 41
  • Thanks for your answer. Is there any way to join the tables and retrieve the data with flask other than injecting the SQL query directly? – NSP Oct 27 '17 at 04:08