0

We have built a series a forms using PHP that populate a MySQL Database and after learning more Python want to begin transitioning our whole web app over to a python back end instead of PHP. Can anyone offer a quick intro into searching a MySQL DB using Python?

mcclaskiem
  • 394
  • 1
  • 15

2 Answers2

0

The easiest way is to abstract the database using an ORM. I found that the python package SQLAlchemy works fantastically.

A ORM let's you treat the database objects as normal python objects. Most queries can be abstracted and for 99% of cases you won't need to write SQL queries. Also this makes transition between database technologies very simple.

Go check it out on:

http://www.sqlalchemy.org/

A search query would be something like:

session.query(User).filter_by(first_name='bob')

Now you will have all users with the first name 'bob'

cchristelis
  • 1,985
  • 1
  • 13
  • 17
0

You search it the same way you would in PHP; because the queries you are using will not change.

The only difference is the driver you have to use.

Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284