Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
error when dealing with uuid
#19
(Apr-13-2021, 12:10 PM)snippsat Wrote: There is no reason to use phpMyAdmin/XAMPP when using Flask,i would never use it this Python usage not PHP.
The standard way to deal to with database in Flask is to use Flask-SQLAlchemy.
Then use DATABASE_URI to connect to database of choice.
So the setup could look like this.
from flask import Flask
from flask_sqlalchemy import SQLAlchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://username:password@server/db'
db = SQLAlchemy(app)


class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(80), unique=True)
    email = db.Column(db.String(120), unique=True)

    def __repr__(self):
        return f'User {self.username} Email {self.email}'
Can look this post there you see a full setuo using sqlite3 so only one line URI change to eg switch to use MySQL.

I use the XAMPP to manage APACHE install and MYSQL. I will try to migrate to Flask-SQLAlchemy.
Reply


Messages In This Thread
error when dealing with uuid - by vj78 - Apr-10-2021, 02:07 PM
RE: error when dealing with uuid - by ibreeden - Apr-11-2021, 09:42 AM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 10:26 AM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 10:26 AM
RE: error when dealing with uuid - by ibreeden - Apr-11-2021, 11:52 AM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 02:39 PM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 03:14 PM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 05:34 PM
RE: error when dealing with uuid - by ibreeden - Apr-11-2021, 06:14 PM
RE: error when dealing with uuid - by vj78 - Apr-11-2021, 09:23 PM
RE: error when dealing with uuid - by vj78 - Apr-12-2021, 01:10 AM
RE: error when dealing with uuid - by ibreeden - Apr-12-2021, 07:33 AM
RE: error when dealing with uuid - by vj78 - Apr-12-2021, 09:03 AM
RE: error when dealing with uuid - by ibreeden - Apr-12-2021, 10:25 AM
RE: error when dealing with uuid - by vj78 - Apr-12-2021, 02:17 PM
RE: error when dealing with uuid - by ibreeden - Apr-12-2021, 05:59 PM
RE: error when dealing with uuid - by vj78 - Apr-13-2021, 12:16 AM
RE: error when dealing with uuid - by snippsat - Apr-13-2021, 12:10 PM
RE: error when dealing with uuid - by vj78 - Apr-13-2021, 01:25 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020