I have a very simple CRUD API:
from bottle import get, post, put, delete, run
@get('/items/')
@get('/items')
def item_list():
return "LIST"
@get('/items/<upc>')
def item_show( upc="0000" ):
return "SHOW ITEM WITH UPC " + upc
@delete('/items/<upc>')
def item_delete( upc="0000" ):
return "DELETE ITEM WITH UPC " + upc
@put('/items/<upc>')
def item_save( upc="0000" ):
return "SAVE ITEM WITH UPC " + upc
@post('/items/<upc>')
def item_create( upc="0000" ):
return "CREATE ITEM WITH UPC " + upc
run()
This works fine, I can run the server and hit all the endpoints and get the correct strings back. But if I add:
from sqlalchemy import *
to the top then when I try to run the server I get this error:
Traceback (most recent call last):
File "app.py", line 14, in <module>
def item_delete( upc="0000" ):
TypeError: 'Delete' object is not callable
What am I doing wrong?
My guess is that
sqlalchemyhas something with the namedeletewhich overrides thefrom bottle import delete.You can solve this by instead doing just
import sqlalchemyor just importing the functions you need fromsqlalchemy(likefrom sqlalchemy import function_you_need, object_you_need).