Exemple #1
0
from flask import Flask, request, flash, url_for, redirect, render_template
from flask_sqlalchemy import sqlalchemy

app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///students.sqlite3'
app.config['SECRET_KEY'] = "random string"

db = sqlalchemy(app)


class Students(db.Model):
    id = db.Column('student_id', db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    city = db.Column(db.String(50))
    addr = db.Column(db.String(200))
    pin = db.Column(db.String(10))

    def __init__(self, name, city, addr, pin):
        self.name = name
        self.city = city
        self.addr = addr
        self.pin = pin


@app.route('/')
def show_all():
    return render_template('show_all.html', students=Students.query.all())


@app.route('/new', methods=['GET', 'POST'])
def new():
Exemple #2
0
import pymysql
pymysql.install_as_MySQLdb()
from flask_sqlalchemy import SQLAlchemy as sqlalchemy
from sqlalchemy import create_engine, text

db = sqlalchemy()

class MigrationMetrics(db.Model):
  __bind_key__ = 'migration_metrics'
  __tablename__ = 'migration_metrics'
  id = db.Column(db.Integer, primary_key=True)
  source_include_line_count = db.Column(db.Integer)
  migration_id = db.Column(db.Integer)
  created_at = db.Column(db.DateTime)
  updated_at = db.Column(db.DateTime)
  destination_include_line_count = db.Column(db.Integer)
  source_mailbox_count = db.Column(db.Integer)
  source_aa_recording_count = db.Column(db.Integer)
  source_sip_endpoint_count = db.Column(db.Integer)
  source_context_line_count = db.Column(db.Integer)
  source_endpoint_ips = db.Column(db.Text)

  def __init__(self,
               source_include_line_count,
               migration_id,
               created_at,
               updated_at,
               destination_include_line_count,
               source_mailbox_count,
               source_aa_recording_count,
               source_sip_endpoint_count,
Exemple #3
0
from flask import Flask
from flask_sqlalchemy import SQLAlchemy as sqlalchemy

app = Flask(__name__)
app.config.from_object('config')
db = sqlalchemy(app)

from app import views, models