Python Forum
How to format a datetime MySQL database field to local using strftime()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to format a datetime MySQL database field to local using strftime()
#1
I decided to move from 'pymysql' to 'bottle-pymysql' plugin. i have this code:

# dbhost is optional, default is localhost
plugin = bottle_pymysql.Plugin( dbuser='nikos', dbpass='*******', dbname='counters', charset = 'utf8' )
app.install(plugin)

.....
.....

for visit in visits:
		visit = visit.strftime('%A %e %b,  %I:%M %p')
When trying to read that view, bottle() gives me this error:

Output:
Traceback: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib/python3.6/site-packages/bottle_pymysql.py", line 174, in wrapper rv = callback(*args, **kwargs) File "/home/nikos/wsgi/www.py", line 132, in log visit = visit.strftime('%A %e %b, %I:%M %p') AttributeError: 'str' object has no attribute 'strftime'
What does this error mean?

I don'understand it, because before using bottle_pymysql i uses pymysql adn that line was interpreted correctly. Now with bottle_pymysql it does not. What can i do?
Thank you.

and also this error:

@app.route( '/' )
@auth_basic(is_authenticated_user)
def index( pymydb ):

	pdata = ''
	names = []

	pymydb.execute( '''SELECT name, phone, hits, money FROM clients ORDER BY hits DESC''' )
	data = pymydb.fetchall()
Output:
TypeError("index() missing 1 required positional argument: 'pymydb'",) Traceback: Traceback (most recent call last): File "/usr/lib64/python3.6/site-packages/bottle.py", line 862, in _handle return route.call(**args) File "/usr/lib64/python3.6/site-packages/bottle.py", line 1740, in wrapper rv = callback(*a, **ka) File "/usr/lib64/python3.6/site-packages/bottle.py", line 2690, in wrapper return func(*a, **ka) TypeError: index() missing 1 required positional argument: 'pymydb'
Reply


Messages In This Thread
How to make bottle-pymysql work - by nikos - Feb-24-2019, 04:41 PM
RE: How to make bottle-pymysql work - by buran - Feb-24-2019, 04:42 PM
RE: How to make bottle-pymysql work - by nikos - Feb-24-2019, 04:43 PM
RE: How to make bottle-pymysql work - by buran - Feb-24-2019, 04:48 PM
RE: How to make bottle-pymysql work - by nikos - Feb-24-2019, 04:56 PM
RE: How to make bottle-pymysql work - by nikos - Feb-24-2019, 06:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  User Input to mySQL database newbie1 3 4,185 Aug-26-2020, 10:42 AM
Last Post: newbie1
  Flask export/upload database table in cvs/xlsx format steve87bg 4 6,844 Jun-19-2020, 01:46 PM
Last Post: steve87bg
  MySQL Database Flask maurosmartins 0 1,818 Oct-03-2019, 10:56 AM
Last Post: maurosmartins
  mysql database error brecht83 1 5,015 Dec-14-2018, 01:25 PM
Last Post: jeanMichelBain

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020