Code Monkey home page Code Monkey logo

Comments (2)

HikariPL avatar HikariPL commented on June 20, 2024

Dear All, any ideas how to fix it?

from flask-admin.

agxc avatar agxc commented on June 20, 2024

No the issue cannot be resolved by use_setinputsizes=False. It is not working. I tried the following code. Not working at all

import argparse
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_admin import Admin
from flask_admin.contrib.sqla import ModelView
from sqlalchemy import create_engine

app = Flask(__name__)

# Setup the Flask app
app.config['SECRET_KEY'] = 'mysecret'
app.config['SQLALCHEMY_DATABASE_URI'] = "YOUR SQL SERVER DB connection"
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

# Optionally, if you want to perform some operations directly with the engine, you can create it like this:
engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'], echo=True, use_setinputsizes=False)

class User(db.Model):
    __tablename__ = 'user'
    __table_args__ = {'schema': 'DevApp'}
    
    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(150), unique=True)
    email = db.Column(db.String(150))

admin = Admin(app, name='My App Admin', template_mode='bootstrap3')
admin.add_view(ModelView(User, db.session))

def create_db():
    """Creates the database tables."""
    with app.app_context():
        db.create_all()
        print('Database tables created successfully.')

def drop_db():
    """Drops the database tables."""
    with app.app_context():
        db.drop_all()
        print('Database tables dropped successfully.')

def run_app():
    app.run(debug=True)

def main():
    parser = argparse.ArgumentParser(description="Manage the Flask application.")
    parser.add_argument('command', choices=['run', 'create_db', 'drop_db'],
                        help='the command to run')
    args = parser.parse_args()
    
    if args.command == 'run':
        run_app()
    elif args.command == 'create_db':
        create_db()
    elif args.command == 'drop_db':
        drop_db()

if __name__ == '__main__':
    main()

from flask-admin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.