Giter VIP home page Giter VIP logo

flask-moresql's People

Contributors

ema avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flask-moresql's Issues

URL 'variables' not working ie. /route/<var1>/<var2>

Good day,
After having my head broken (again) on the code, I finally found why the above won't work, typically for two or more (and not that well documented that it will or won't) but only the case of HTTP variables to be passed as URL routes/paths.

The following fails as it doesn't send any parameters to the PostgreSQL stored procedure:

@app.route('/switch/<ref>/<uuid>',methods=['GET'])
def doswitch(ref,uuid):
    return db.execute('switchproc',fields=['ref','uuid'])

It's tested that in the case where I'm using variables like 'http://localhost/route?var1=value&var2=morevalue' it works fine, ie.:

@app.route('/user', methods=['GET'])
def get_user_data():
    return db.execute('get_user', fields=['curpair', 'ref'])

Looking at the code, it appears to assume that we'll aways be using the variable and not the url path method, looking at line 128 of https://github.com/ema/flask-moresql/blob/master/flask_moresql.py :

        procargs = _get_procedure_arguments(fields, values)

example

Hi there! Can you provide an SQL script (or something like that) to initialize the database used by the example.py app?

Not cleaning/rollback after stored procedure failure

Hi there,

After a stored procedure call failure, there is a need for the session to have the transaction rolled back, but then it isn't by Flask-MoreSQL, and any further requests failed with an
InternalError: current transaction is aborted, commands ignored until end of transaction block error, as in:

Traceback (most recent call last):
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1836, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1820, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1403, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/***/dev/quote-api/flask_pg.py", line 48, in indicate
    return db.execute('getIndQuote',fields=['curpairreq']);
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/flask_moresql.py", line 130, in execute
    result = self.cursor.callproc(procname, procargs)
  File "/home/***/dev/quote-api/flask/lib/python2.7/site-packages/psycopg2/extras.py", line 228, in callproc
    return super(RealDictCursor, self).callproc(procname, vars)
InternalError: current transaction is aborted, commands ignored until end of transaction block

-->

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.