mirror of
https://github.com/skylanix/MamieHenriette.git
synced 2026-02-13 11:50:37 +01:00
Premier jet acces BDD
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
__pycache__
|
__pycache__
|
||||||
|
instance
|
||||||
|
|||||||
@@ -4,5 +4,5 @@ python-dotenv==1.0.0
|
|||||||
aiohttp>=3.7.4,<4
|
aiohttp>=3.7.4,<4
|
||||||
audioop-lts; python_version>='3.13'
|
audioop-lts; python_version>='3.13'
|
||||||
|
|
||||||
flask==2.3.2
|
flask>=2.3.2
|
||||||
#flask-sqlalchemy==3.0.3
|
flask-sqlalchemy>=3.0.3
|
||||||
6
schema.sql
Normal file
6
schema.sql
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `message` (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
`enable` BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
|
`text` VARCHAR(256) NULL,
|
||||||
|
periodicity INTEGER NULL
|
||||||
|
);
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
from flask import Flask
|
from flask import Flask
|
||||||
# from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
# import os
|
from sqlalchemy.sql import text
|
||||||
|
|
||||||
# file_path = os.path.abspath(os.getcwd())+"/todo.db"
|
|
||||||
|
|
||||||
webapp = Flask(__name__)
|
webapp = Flask(__name__)
|
||||||
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+file_path
|
webapp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///database.db'
|
||||||
# db = SQLAlchemy(app)
|
db = SQLAlchemy(webapp)
|
||||||
|
|
||||||
from webapp import routes
|
from webapp import routes
|
||||||
|
|
||||||
|
with webapp.app_context():
|
||||||
|
with open('schema.sql', 'r') as f:
|
||||||
|
sql_script = f.read()
|
||||||
|
db.session.execute(text(sql_script))
|
||||||
|
db.session.commit()
|
||||||
|
|||||||
8
webapp/models.py
Normal file
8
webapp/models.py
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
from webapp import db
|
||||||
|
|
||||||
|
class Message(db.Model):
|
||||||
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
enable = db.Column(db.Boolean, default=False)
|
||||||
|
text = db.Column(db.String(200))
|
||||||
|
# en seconde
|
||||||
|
periodicity = db.Column(db.Integer)
|
||||||
@@ -1,6 +1,10 @@
|
|||||||
from flask import Flask, render_template
|
from flask import Flask, render_template
|
||||||
from webapp import webapp
|
from webapp import webapp, db
|
||||||
|
from webapp.models import Message
|
||||||
|
|
||||||
@webapp.route("/")
|
@webapp.route("/")
|
||||||
def index():
|
def index():
|
||||||
|
# message = Message(text="bla bla", periodicity = 3600)
|
||||||
|
# db.session.add(message)
|
||||||
|
# db.session.commit()
|
||||||
return render_template("index.html")
|
return render_template("index.html")
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
<li><a href="/">Modération</a></li>
|
<li><a href="/">Modération</a></li>
|
||||||
<li><a href="/">Messages</a></li>
|
<li><a href="/">Messages</a></li>
|
||||||
<li><a href="/">Commandes</a></li>
|
<li><a href="/">Commandes</a></li>
|
||||||
|
<li><a href="/">Configuration</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
Reference in New Issue
Block a user