Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Issue with bottle-pymysql
#1
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",)
Quote
#2
Someone please?
Quote
#3
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",)
Quote
#4
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
Quote
#5
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.
Quote
#6
try
@app.route('/log/<page>')
def log(page, pymydb):
Quote
#7
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
Quote
#8
(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
Quote
#9
for the second one try
def index(pymydb, page='index.html'):
it looks like pymydb should be last positional argument
Quote
#10
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?
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  pymysql.err.InterfaceError nikos 1 139 Feb-24-2019, 02:07 PM
Last Post: nikos
  How to access routes using Bottle Framework nikos 5 213 Feb-13-2019, 11:43 PM
Last Post: nikos
  unable to import pymysql IMuriel 3 339 Jan-08-2019, 08:56 PM
Last Post: IMuriel
  Passing a query value from a Bottle html template to a route with an encoding nikos 0 360 Sep-30-2018, 03:29 AM
Last Post: nikos
  Insert data to SQL through pymysql and flask iainstott 3 2,618 Oct-24-2017, 03:04 PM
Last Post: iainstott
  please explain Bottle runtime log Kebap 4 2,487 Sep-22-2016, 05:40 PM
Last Post: snippsat

Forum Jump:


Users browsing this thread: 1 Guest(s)