Skip to content

The extension provides facilites for implementing Django-like "./manage.py dbshell" command

Notifications You must be signed in to change notification settings

tyctor/flask-dbshell

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flask DbShell

The extension provides facilites for implementing Django-like ./manage.py dbshell command

Installation

Install the extension with one of the following commands:

$ easy_install flask-dbshell

or alternatively if you have pip installed:

$ pip install flask-dbshell

How to use

Example of a simple script that runs mysql's shell

from flask.ext.dbshell import DbShell


def main():
    dbshell = DbShell('mysql://scott:tiger@server/dbname')
    dbshell.run_shell()
    

if __name__ == '__main__':
    main()

Example of use with Flask-Script:

from flask import Flask
from flask.ext.script import Manager
from flask.ext.dbshell import DbShell


class DevConfig(object):
    DATABASE_URI = 'sqlite:///demo.sqlite'


app = Flask(__name__)
app.config.from_object(DevConfig)
manager = Manager(app)


@manager.command
def dbshell():
    shell = DbShell(url=app.config['DATABASE_URI'])
    shell.run_shell()


if __name__ == "__main__":
    manager.run()

Python versions supported

Tested with 2.6.x and 2.7.x

About

The extension provides facilites for implementing Django-like "./manage.py dbshell" command

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%