Re: [sqlalchemy] Working with func in dates, No response, no error message

2023-04-04 Thread Nancy Andeyo
I am still struggling to find the solution on this issue, the issue is with
the func, because when I omit the comparison with the the func
sqlachemy function, the outcome is expected. However, I want to ensure that
only items for this month are displayed:
he filter *.filter(func.strftime('%m', func.date(Events.date_of_event) ==
current_month = datetime.today().strftime('%m')))* to get all the events
that happened in the current month is not working. But displays all the
events. Help me figure out the problem. I am using SQLite and sqlalchemy
with Flask to query the db.  I have imported the `func` from sqlalchemy as
well as `datetime ` from `datetime` as required.

On Fri, Mar 31, 2023 at 8:22 AM James Paul Chibole 
wrote:

>
> Thank you Philip for your suggestion.
> On Thursday, March 30, 2023 at 9:38:08 PM UTC+3 Philip Semanchuk wrote:
>
>>
>>
>> > On Mar 30, 2023, at 2:32 PM, James Paul Chibole 
>> wrote:
>> >
>> > Hi everyone, I am trying to retrieve deceased persons who died in the
>> current month but the output gives no result. Here is my code with query
>> done in Python Flask:
>> > from datetime import datetime from sqlalchemy import func
>> > @app.route('/user/') @login_required def user(username):
>> current_month = datetime.today().date().strftime("%B")
>> monthly_anniversaries =
>> current_user.followed_deaths().filter(Deceased.burial_cremation_dat e
>> > f_death== current_month)).order_by(Deceased.timestamp.desc()) return
>> render_template("user.html", monthly_anniversaries =monthly_anniversaries)
>>
>>
>> Flask is an extra layer of complication here that’s getting in the way of
>> what you’re trying to debug. That’s not a knock on Flask (I use it too),
>> it’s just not germane to a SQLAlchemy problem. My suggestion is that you
>> try putting a breakpoint in your flask app so you can play with the query
>> inside the debugger. Ensure that current_month is what you think it is,
>> hardcode query params instead of passing variables to see if that changes
>> results, remove some of the filter clauses to see if the results change the
>> way you expect, etc. And of course having a look at the SQL that’s being
>> sent to the server will give you some clues too, although that can be hard
>> to get to depending on your environment.
>>
>>
>> Hope this helps
>> Philip
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/f6a17840-cdfd-4f26-bdc5-0a75af82fa91n%40googlegroups.com
> 
> .
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAJiyv_2oLnfo%3DD56fkrYGt3sCoK7vPz-BKQAb7cm9VHsdaKwZw%40mail.gmail.com.


Re: [sqlalchemy] Working with func in dates, No response, no error message

2023-04-04 Thread Nancy Andeyo
I am still struggling to find the solution on this issue, the issue is with
the func, because when I omit the comparison with the func
sqlalchemy function, the outcome is expected. However, I want to ensure
that only items for this month are displayed:
he filter *.filter(func.strftime('%m', func.date(Events.date_of_event) ==
datetime.today().strftime('%m')))* to get all the events that happened in
the current month is not working. But displays all the events. Help me
figure out the problem. I am using SQLite and sqlalchemy with Flask to
query the db.  I have imported the `func` from sqlalchemy as well as
`datetime ` from `datetime` as required.

On Fri, Mar 31, 2023 at 8:22 AM James Paul Chibole 
wrote:

>
> Thank you Philip for your suggestion.
> On Thursday, March 30, 2023 at 9:38:08 PM UTC+3 Philip Semanchuk wrote:
>
>>
>>
>> > On Mar 30, 2023, at 2:32 PM, James Paul Chibole 
>> wrote:
>> >
>> > Hi everyone, I am trying to retrieve deceased persons who died in the
>> current month but the output gives no result. Here is my code with query
>> done in Python Flask:
>> > from datetime import datetime from sqlalchemy import func
>> > @app.route('/user/') @login_required def user(username):
>> current_month = datetime.today().date().strftime("%B")
>> monthly_anniversaries =
>> current_user.followed_deaths().filter(Deceased.burial_cremation_dat e
>> > f_death== current_month)).order_by(Deceased.timestamp.desc()) return
>> render_template("user.html", monthly_anniversaries =monthly_anniversaries)
>>
>>
>> Flask is an extra layer of complication here that’s getting in the way of
>> what you’re trying to debug. That’s not a knock on Flask (I use it too),
>> it’s just not germane to a SQLAlchemy problem. My suggestion is that you
>> try putting a breakpoint in your flask app so you can play with the query
>> inside the debugger. Ensure that current_month is what you think it is,
>> hardcode query params instead of passing variables to see if that changes
>> results, remove some of the filter clauses to see if the results change the
>> way you expect, etc. And of course having a look at the SQL that’s being
>> sent to the server will give you some clues too, although that can be hard
>> to get to depending on your environment.
>>
>>
>> Hope this helps
>> Philip
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full
> description.
> ---
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sqlalchemy/f6a17840-cdfd-4f26-bdc5-0a75af82fa91n%40googlegroups.com
> 
> .
>

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAJiyv_2PGNitc7tJgafxQ7fKM-JD5if53knb2iaoujMvesxeVw%40mail.gmail.com.


Re: [sqlalchemy] Working with func in dates, No response, no error message

2023-03-30 Thread James Paul Chibole

Thank you Philip for your suggestion.
On Thursday, March 30, 2023 at 9:38:08 PM UTC+3 Philip Semanchuk wrote:

>
>
> > On Mar 30, 2023, at 2:32 PM, James Paul Chibole  
> wrote:
> > 
> > Hi everyone, I am trying to retrieve deceased persons who died in the 
> current month but the output gives no result. Here is my code with query 
> done in Python Flask:
> > from datetime import datetime from sqlalchemy import func 
> > @app.route('/user/') @login_required def user(username): 
> current_month = datetime.today().date().strftime("%B") 
> monthly_anniversaries = 
> current_user.followed_deaths().filter(Deceased.burial_cremation_dat e 
>  f_death== current_month)).order_by(Deceased.timestamp.desc()) return 
> render_template("user.html", monthly_anniversaries =monthly_anniversaries)
>
>
> Flask is an extra layer of complication here that’s getting in the way of 
> what you’re trying to debug. That’s not a knock on Flask (I use it too), 
> it’s just not germane to a SQLAlchemy problem. My suggestion is that you 
> try putting a breakpoint in your flask app so you can play with the query 
> inside the debugger. Ensure that current_month is what you think it is, 
> hardcode query params instead of passing variables to see if that changes 
> results, remove some of the filter clauses to see if the results change the 
> way you expect, etc. And of course having a look at the SQL that’s being 
> sent to the server will give you some clues too, although that can be hard 
> to get to depending on your environment.
>
>
> Hope this helps
> Philip

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/f6a17840-cdfd-4f26-bdc5-0a75af82fa91n%40googlegroups.com.


Re: [sqlalchemy] Working with func in dates, No response, no error message

2023-03-30 Thread Philip Semanchuk



> On Mar 30, 2023, at 2:32 PM, James Paul Chibole  wrote:
> 
> Hi everyone, I am trying to retrieve deceased persons who died in the current 
> month but the output gives no result. Here is my code with query done in 
> Python Flask:
> from datetime import datetime  from 
> sqlalchemy import func  
> @app.route('/user/')@login_required 
> def user(username):
> current_month = datetime.today().date().strftime("%B")   
> monthly_anniversaries =   
> current_user.followed_deaths().filter(Deceased.burial_cremation_dat  e  
>  f_death== current_month)).order_by(Deceased.timestamp.desc())  return 
> render_template("user.html", monthly_anniversaries =monthly_anniversaries)


Flask is an extra layer of complication here that’s getting in the way of what 
you’re trying to debug. That’s not a knock on Flask (I use it too), it’s just 
not germane to a SQLAlchemy problem. My suggestion is that you try putting a 
breakpoint in your flask app so you can play with the query inside the 
debugger. Ensure that current_month is what you think it is, hardcode query 
params instead of passing variables to see if that changes results, remove some 
of the filter clauses to see if the results change the way you expect, etc.  
And of course having a look at the SQL that’s being sent to the server will 
give you some clues too, although that can be hard to get to depending on your 
environment.


Hope this helps
Philip

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/D9E83ABA-9E34-4375-A0AB-E986B96B6794%40americanefficient.com.


[sqlalchemy] Working with func in dates, No response, no error message

2023-03-30 Thread James Paul Chibole


Hi everyone, I am trying to retrieve deceased persons who died in the 
current month but the output gives no result. Here is my code with query 
done in Python Flask:
from datetime import datetime  from 
sqlalchemy import func  
@app.route('/user/')@login_required  
   def user(username):   
 current_month = datetime.today().date().strftime("%B")  
 monthly_anniversaries =  
 current_user.followed_deaths().filter(Deceased.burial_cremation_dat  e
  http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/3b972e00-e172-402a-983d-30ef7e22aef7n%40googlegroups.com.