Issue with bottle-pymysql - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Issue with bottle-pymysql (/thread-16112.html) Pages:
1
2
|
Issue with bottle-pymysql - nikos - Feb-14-2019 plugin = bottle_pymysql.Plugin( dbuser='nikos', dbpass='******', dbname='counters', charset = 'utf8', keyword='pymydb' ) app.install(plugin) # calculate total hits for each and every webpage pymydb.execute( '''SELECT url from pages ORDER by hits ASC''' )When i try to run the script i get the error:
RE: Issue with bottle-pymysql - nikos - Feb-19-2019 Someone please? name 'pymydb' is not defined - nikos - Feb-19-2019 plugin = bottle_pymysql.Plugin( dbuser='nikos', dbpass='******', dbname='counters', charset = 'utf8', keyword='pymydb' ) app.install(plugin) # calculate total hits for each and every webpage pymydb.execute( '''SELECT url from pages ORDER by hits ASC''' ) def database( pymydb, page ): .... ....When i try to run the script i get the error: Output:
RE: Issue with bottle-pymysql - buran - Feb-19-2019 Not 100% sure, I think but this will have effect only in route, e.g. something like @app.route('/hits') def hits(pymydb): pymydb.execute( '''SELECT url from pages ORDER by hits ASC''' ) # rest of it to render the page RE: Issue with bottle-pymysql - nikos - Feb-19-2019 Yes, you are right, i have removed it from the function and put it only in the route @app.route( '/log/<page>' ) def log( pymydb, page ):But still iam getting the same error. RE: Issue with bottle-pymysql - buran - Feb-19-2019 try @app.route('/log/<page>') def log(page, pymydb): RE: Issue with bottle-pymysql - nikos - Feb-19-2019
and if @app.route( '/' ) @app.route( '/<page>' ) def index( page='index.html', pymydb ):
RE: Issue with bottle-pymysql - buran - Feb-19-2019 (Feb-19-2019, 04:52 PM)nikos Wrote: Output: So, obviously this works. The AttributeError is due to something else in your code RE: Issue with bottle-pymysql - buran - Feb-19-2019 for the second one try def index(pymydb, page='index.html'):it looks like pymydb should be last positional argument RE: Issue with bottle-pymysql - nikos - Feb-19-2019 First positional arg you mean. I dont have anything else wrong AttributeError: 'NoneType' object has no attribute 'encoding' is refering to pymydb, perhaps it has no value? |