Python Forum
SQLAlchemy DateTime result 0's
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SQLAlchemy DateTime result 0's
#1
Hi all, I am new here and also quite new to python, so I apologize in advance for any errors I may make, just let me know any I will prevent it in the future, thank you.

So My current function is using flask, having a form to book an appointment, so far in my template for the time part is:
<form action="/patient/patientbook" method="POST" role="form"> <label for="name">Start Time:</label> <input type="datetime-local" class="form-control" id="starttime" name="starttime" required> <br> </form>
And inside my python script:
# Databse model for a Booking class Book(db.Model): __tablename__ = 'booking' bid = db.Column(db.Integer, primary_key=True) starttime = db.Column(db.DateTime(), nullable=False) count = 1 def __init__(self, starttime): self.starttime = Book.starttime Book.count += 1 class BookSchema(ma.Schema): class Meta: # Fields to expose fields = ('bid', 'starttime') book_schema = BookSchema() books_schema = BookSchema(many=True) # Route for a patient to make a booking @app.route("/patient/patientbook", methods=["POST", "GET"]) def patientBook(): if request.method == 'POST': pemail = (request.form.get('email')) pname = (request.form.get('pname')) starttime = request.form['starttime'] print(starttime) starttime = "{}:00".format(starttime) print(starttime) if pemail and pname and starttime: new_booking = Patient(pemail, pname) new_bookingtwo = Book(starttime) db.session.add(new_booking) db.session.add(new_bookingtwo) db.session.commit() return render_template('patient/patientbook.html')
And After I have completed the process and view the results in the database (google cloud db),
I receive the following:

Output:
MySQL [crud]> select * from booking; +-----+---------------------+ | bid | starttime | +-----+---------------------+ | 1 | 0000-00-00 00:00:00 | | 2 | 0000-00-00 00:00:00 | | 3 | 0000-00-00 00:00:00 | +-----+---------------------+ 3 rows in set (0.11 sec)
Any help appreciated!

Also another thing, I am working on linking up my database so that a Doctor will be linked with an appointment time with a patients email, any guide on how to do that would also be appreciated,
Thank you!!!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Confusion with datetime 'dst' function result jsmith1703 4 5,399 Nov-16-2019, 02:55 AM
Last Post: DeaD_EyE
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str' findbikash 2 12,733 Sep-18-2019, 08:32 AM
Last Post: buran
  Erratic Datetime result timsch 0 2,901 Dec-27-2018, 01:49 AM
Last Post: timsch
  datetime unexpected result PickyBiker 10 12,512 Dec-27-2016, 10:47 PM
Last Post: PickyBiker

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.