Python Forum
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:

Output:
NameError("name 'pymydb' is not defined",)



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:

Output:
NameError("name 'pymydb' is not defined",)



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

Output:
AttributeError: 'NoneType' object has no attribute 'encoding'

and if

@app.route( '/' )
@app.route( '/<page>' )
def index( page='index.html', pymydb ):
Output:
[Tue Feb 19 18:56:49.296522 2019] [wsgi:error] [pid 31673] [remote 176.92.27.182:1210] SyntaxError: non-default argument follows default argument



RE: Issue with bottle-pymysql - buran - Feb-19-2019

(Feb-19-2019, 04:52 PM)nikos Wrote: Output:
AttributeError: 'NoneType' object has no attribute 'encoding'

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?