From mhysnm1964 at gmail.com Mon Aug 5 06:25:21 2019 From: mhysnm1964 at gmail.com (mhysnm1964 at gmail.com) Date: Mon, 5 Aug 2019 20:25:21 +1000 Subject: [Flask] Flasks and forms query Message-ID: <011e01d54b78$17ef5fe0$47ce1fa0$@gmail.com> All, I am fairly new to Python and Flask. So there is a lot of concepts I will not understand. So please bare with me if I don't use the right terminology. The issue I am having is with flask_wtf and forms. I am using SelectFields which I want to grab the selected item from the list of options. I cannot get the data from the selector. If there is five items and I select the 2nd option. I want the value related to option 2 to be retrieved and updating a database. Below is the information I hope will make things clear. HTML template: {% extends "base.html" %} {% block content %}

New Sub Category

{{ form.hidden_tag() }} {{ form.categoriesfield.label }} {{ form.categoriesfield(rows=10) }}

{{ form.subcategoryfield.label }}
{{ form.subcategoryfield(size=64) }}
{% for error in form.subcategoryfield.errors %} [{{ error }}] {% endfor %}

{{ form.submit() }}

. More HTML is here but not related to the question. {% endblock %} Now for the form.py class related to this form: from flask_wtf import FlaskForm from wtforms import StringField, BooleanField, SubmitField, TextAreaField, TextField, IntegerField, RadioField, SelectField, SelectMultipleField from wtforms.validators import ValidationError, DataRequired, EqualTo, Length from app.models import * # all table model classes class SubCategoryForm (FlaskForm): categoriesfield = SelectField('Categories', choices= [(c.id, c.category) for c in Categories.query.order_by('category')]) subcategoryfield = StringField('Sub Category Name') submit = SubmitField('Create SubCategory') Now for the routes.py function which the issue occurs. As you can tell below, I am passing the category id and category text value to the SelectField field to create the HTML code. The text value is being displayed and I want the ID to be retrieved. Then I am planning to update the SubCategory table with the category id to establish the relationship for a new sub_category. from datetime import datetime from flask import render_template, flash, redirect, url_for, request from app import app, db from app.forms import CategoryForm, SubCategoryForm from app.models import * # all table model classes @app.route('/subcategories', methods=['GET', 'POST']) def subcategories (): tables = Accounts.query.all() form = SubCategoryForm() print (form.categoriesfield.data) if form.validate_on_submit(): subcategory_value = SubCategories(subcategory=form.subcategory.data) db.session.add(subcategory_value) db.session.commit() flash('Congratulations, a sub category was added. {} {}'.format(subcategory_value, form.categoriesfield.data)) return redirect(url_for('subcategories')) page = request.args.get('page', 1, type=int) records = SubCategories.query.order_by(SubCategories.id).paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('subcategories', page=records.next_num) if records.has_next else None prev_url = url_for('subcategories', page=records.prev_num) if records.has_prev else None return render_template('subcategories.html', tables = tables, title='Manage sub Categories', form=form, records = records.items, next_url = next_url, prev_url = prev_url) I cannot work how to get the category ID. If I use validate or not on any fields, it doesn't produce anything in the flash. The page refreshes and leave the content in the field. The database isn't being updated with the new sub_category. All the database relationships are working when I manually insert the data into the table via SQLIte3. Any thoughts? Have I made myself clear enough? Sean -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Mon Aug 5 07:21:31 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 5 Aug 2019 07:21:31 -0400 Subject: [Flask] Flasks and forms query In-Reply-To: <011e01d54b78$17ef5fe0$47ce1fa0$@gmail.com> References: <011e01d54b78$17ef5fe0$47ce1fa0$@gmail.com> Message-ID: Perhaps this... SubCategories(subcategory=form.subcategory.data) should be this... SubCategories(subcategory=form.subcategoryfield.data) On Mon, Aug 5, 2019 at 6:25 AM wrote: > All, > > > > I am fairly new to Python and Flask. So there is a lot of concepts I will > not understand. So please bare with me if I don?t use the right terminology. > > > > The issue I am having is with flask_wtf and forms. I am using SelectFields > which I want to grab the selected item from the list of options. I cannot > get the data from the selector. If there is five items and I select the 2 > nd option. I want the value related to option 2 to be retrieved and > updating a database. Below is the information I hope will make things clear. > > > > HTML template: > > > > {% extends "base.html" %} > > > > {% block content %} > >

New Sub Category

> >
> > {{ form.hidden_tag() }} > > {{ form.categoriesfield.label }} > > {{ form.categoriesfield(rows=10) }} > >

> > {{ form.subcategoryfield.label }}
> > {{ form.subcategoryfield(size=64) }}
> > {% for error in form.subcategoryfield.errors %} > > [{{ error }}] > > {% endfor %} > >

> >

{{ form.submit() }}

> >
> > ? More HTML is here but not related to the question. > > {% endblock %} > > > > Now for the form.py class related to this form: > > > > from flask_wtf import FlaskForm > > from wtforms import StringField, BooleanField, SubmitField, > TextAreaField, TextField, IntegerField, RadioField, SelectField, > SelectMultipleField > > from wtforms.validators import ValidationError, DataRequired, EqualTo, > Length > > from app.models import * # all table model classes > > > > class SubCategoryForm (FlaskForm): > > categoriesfield = SelectField('Categories', choices= [(c.id, > c.category) for c in Categories.query.order_by('category')]) > > subcategoryfield = StringField('Sub Category Name') > > submit = SubmitField('Create SubCategory') > > > > Now for the routes.py function which the issue occurs. As you can tell > below, I am passing the category id and category text value to the > SelectField field to create the HTML code. The text value is being > displayed and I want the ID to be retrieved. Then I am planning to update > the SubCategory table with the category id to establish the relationship > for a new sub_category. > > > > from datetime import datetime > > from flask import render_template, flash, redirect, url_for, request > > from app import app, db > > from app.forms import CategoryForm, SubCategoryForm > > from app.models import * # all table model classes > > > > @app.route('/subcategories', methods=['GET', 'POST']) > > def subcategories (): > > tables = Accounts.query.all() > > form = SubCategoryForm() > > print (form.categoriesfield.data) > > if form.validate_on_submit(): > > subcategory_value = > SubCategories(subcategory=form.subcategory.data) > > db.session.add(subcategory_value) > > db.session.commit() > > flash('Congratulations, a sub category was added. {} > {}'.format(subcategory_value, form.categoriesfield.data)) > > return redirect(url_for('subcategories')) > > page = request.args.get('page', 1, type=int) > > records = > SubCategories.query.order_by(SubCategories.id).paginate(page, > app.config['POSTS_PER_PAGE'], False) > > next_url = url_for('subcategories', page=records.next_num) if > records.has_next else None > > prev_url = url_for('subcategories', page=records.prev_num) if > records.has_prev else None > > return render_template('subcategories.html', tables = tables, > title='Manage sub Categories', form=form, records = records.items, > next_url = next_url, prev_url = prev_url) > > > > I cannot work how to get the category ID. If I use validate or not on any > fields, it doesn?t produce anything in the flash. The page refreshes and > leave the content in the field. The database isn?t being updated with the > new sub_category. All the database relationships are working when I > manually insert the data into the table via SQLIte3. > > > > Any thoughts? Have I made myself clear enough? > > > > Sean > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhysnm1964 at gmail.com Mon Aug 5 07:43:33 2019 From: mhysnm1964 at gmail.com (Sean Murphy) Date: Mon, 5 Aug 2019 21:43:33 +1000 Subject: [Flask] Flasks and forms query In-Reply-To: References: <011e01d54b78$17ef5fe0$47ce1fa0$@gmail.com> Message-ID: <35FE9163-CD5E-4844-B99D-91E392F391B6@gmail.com> Thanks, I?ve tried that and it didn?t work. I?m gonna remove the F statement for the validation and see if that makes a difference. As I think the validation is causing the issue. My experience is the part > On 5 Aug 2019, at 9:21 pm, Corey Boyle wrote: > > Perhaps this... > SubCategories(subcategory=form.subcategory.data) > should be this... > SubCategories(subcategory=form.subcategoryfield.data) > > >> On Mon, Aug 5, 2019 at 6:25 AM wrote: >> All, >> >> >> >> I am fairly new to Python and Flask. So there is a lot of concepts I will not understand. So please bare with me if I don?t use the right terminology. >> >> >> >> The issue I am having is with flask_wtf and forms. I am using SelectFields which I want to grab the selected item from the list of options. I cannot get the data from the selector. If there is five items and I select the 2nd option. I want the value related to option 2 to be retrieved and updating a database. Below is the information I hope will make things clear. >> >> >> >> HTML template: >> >> >> >> {% extends "base.html" %} >> >> >> >> {% block content %} >> >>

New Sub Category

>> >>
>> >> {{ form.hidden_tag() }} >> >> {{ form.categoriesfield.label }} >> >> {{ form.categoriesfield(rows=10) }} >> >>

>> >> {{ form.subcategoryfield.label }}
>> >> {{ form.subcategoryfield(size=64) }}
>> >> {% for error in form.subcategoryfield.errors %} >> >> [{{ error }}] >> >> {% endfor %} >> >>

>> >>

{{ form.submit() }}

>> >>
>> >> ? More HTML is here but not related to the question. >> >> {% endblock %} >> >> >> >> Now for the form.py class related to this form: >> >> >> >> from flask_wtf import FlaskForm >> >> from wtforms import StringField, BooleanField, SubmitField, TextAreaField, TextField, IntegerField, RadioField, SelectField, SelectMultipleField >> >> from wtforms.validators import ValidationError, DataRequired, EqualTo, Length >> >> from app.models import * # all table model classes >> >> >> >> class SubCategoryForm (FlaskForm): >> >> categoriesfield = SelectField('Categories', choices= [(c.id, c.category) for c in Categories.query.order_by('category')]) >> >> subcategoryfield = StringField('Sub Category Name') >> >> submit = SubmitField('Create SubCategory') >> >> >> >> Now for the routes.py function which the issue occurs. As you can tell below, I am passing the category id and category text value to the SelectField field to create the HTML code. The text value is being displayed and I want the ID to be retrieved. Then I am planning to update the SubCategory table with the category id to establish the relationship for a new sub_category. >> >> >> >> from datetime import datetime >> >> from flask import render_template, flash, redirect, url_for, request >> >> from app import app, db >> >> from app.forms import CategoryForm, SubCategoryForm >> >> from app.models import * # all table model classes >> >> >> >> @app.route('/subcategories', methods=['GET', 'POST']) >> >> def subcategories (): >> >> tables = Accounts.query.all() >> >> form = SubCategoryForm() >> >> print (form.categoriesfield.data) >> >> if form.validate_on_submit(): >> >> subcategory_value = SubCategories(subcategory=form.subcategory.data) >> >> db.session.add(subcategory_value) >> >> db.session.commit() >> >> flash('Congratulations, a sub category was added. {} {}'.format(subcategory_value, form.categoriesfield.data)) >> >> return redirect(url_for('subcategories')) >> >> page = request.args.get('page', 1, type=int) >> >> records = SubCategories.query.order_by(SubCategories.id).paginate(page, app.config['POSTS_PER_PAGE'], False) >> >> next_url = url_for('subcategories', page=records.next_num) if records.has_next else None >> >> prev_url = url_for('subcategories', page=records.prev_num) if records.has_prev else None >> >> return render_template('subcategories.html', tables = tables, title='Manage sub Categories', form=form, records = records.items, next_url = next_url, prev_url = prev_url) >> >> >> >> I cannot work how to get the category ID. If I use validate or not on any fields, it doesn?t produce anything in the flash. The page refreshes and leave the content in the field. The database isn?t being updated with the new sub_category. All the database relationships are working when I manually insert the data into the table via SQLIte3. >> >> >> >> Any thoughts? Have I made myself clear enough? >> >> >> >> Sean >> >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Mon Aug 5 08:02:02 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 5 Aug 2019 08:02:02 -0400 Subject: [Flask] Flasks and forms query In-Reply-To: <35FE9163-CD5E-4844-B99D-91E392F391B6@gmail.com> References: <011e01d54b78$17ef5fe0$47ce1fa0$@gmail.com> <35FE9163-CD5E-4844-B99D-91E392F391B6@gmail.com> Message-ID: If you remove the IF block for validating, then anytime that page is requested (not just form submissions) you will get new DB records created. Is your sub-category model related to the category model? If so, this line " SubCategories(subcategory=form.subcategoryfield.data)" needs to reflect that. On Mon, Aug 5, 2019 at 7:43 AM Sean Murphy wrote: > Thanks, I?ve tried that and it didn?t work. I?m gonna remove the F > statement for the validation and see if that makes a difference. As I think > the validation is causing the issue. > > My experience is the part > > On 5 Aug 2019, at 9:21 pm, Corey Boyle wrote: > > Perhaps this... > SubCategories(subcategory=form.subcategory.data) > should be this... > SubCategories(subcategory=form.subcategoryfield.data) > > > On Mon, Aug 5, 2019 at 6:25 AM wrote: > >> All, >> >> >> >> I am fairly new to Python and Flask. So there is a lot of concepts I will >> not understand. So please bare with me if I don?t use the right terminology. >> >> >> >> The issue I am having is with flask_wtf and forms. I am using >> SelectFields which I want to grab the selected item from the list of >> options. I cannot get the data from the selector. If there is five items >> and I select the 2nd option. I want the value related to option 2 to be >> retrieved and updating a database. Below is the information I hope will >> make things clear. >> >> >> >> HTML template: >> >> >> >> {% extends "base.html" %} >> >> >> >> {% block content %} >> >>

New Sub Category

>> >>
>> >> {{ form.hidden_tag() }} >> >> {{ form.categoriesfield.label }} >> >> {{ form.categoriesfield(rows=10) }} >> >>

>> >> {{ form.subcategoryfield.label }}
>> >> {{ form.subcategoryfield(size=64) }}
>> >> {% for error in form.subcategoryfield.errors %} >> >> [{{ error }}] >> >> {% endfor %} >> >>

>> >>

{{ form.submit() }}

>> >>
>> >> ? More HTML is here but not related to the question. >> >> {% endblock %} >> >> >> >> Now for the form.py class related to this form: >> >> >> >> from flask_wtf import FlaskForm >> >> from wtforms import StringField, BooleanField, SubmitField, >> TextAreaField, TextField, IntegerField, RadioField, SelectField, >> SelectMultipleField >> >> from wtforms.validators import ValidationError, DataRequired, EqualTo, >> Length >> >> from app.models import * # all table model classes >> >> >> >> class SubCategoryForm (FlaskForm): >> >> categoriesfield = SelectField('Categories', choices= [(c.id, >> c.category) for c in Categories.query.order_by('category')]) >> >> subcategoryfield = StringField('Sub Category Name') >> >> submit = SubmitField('Create SubCategory') >> >> >> >> Now for the routes.py function which the issue occurs. As you can tell >> below, I am passing the category id and category text value to the >> SelectField field to create the HTML code. The text value is being >> displayed and I want the ID to be retrieved. Then I am planning to update >> the SubCategory table with the category id to establish the relationship >> for a new sub_category. >> >> >> >> from datetime import datetime >> >> from flask import render_template, flash, redirect, url_for, request >> >> from app import app, db >> >> from app.forms import CategoryForm, SubCategoryForm >> >> from app.models import * # all table model classes >> >> >> >> @app.route('/subcategories', methods=['GET', 'POST']) >> >> def subcategories (): >> >> tables = Accounts.query.all() >> >> form = SubCategoryForm() >> >> print (form.categoriesfield.data) >> >> if form.validate_on_submit(): >> >> subcategory_value = >> SubCategories(subcategory=form.subcategory.data) >> >> db.session.add(subcategory_value) >> >> db.session.commit() >> >> flash('Congratulations, a sub category was added. {} >> {}'.format(subcategory_value, form.categoriesfield.data)) >> >> return redirect(url_for('subcategories')) >> >> page = request.args.get('page', 1, type=int) >> >> records = SubCategories.query.order_by(SubCategories.id).paginate(page, >> app.config['POSTS_PER_PAGE'], False) >> >> next_url = url_for('subcategories', page=records.next_num) if >> records.has_next else None >> >> prev_url = url_for('subcategories', page=records.prev_num) if >> records.has_prev else None >> >> return render_template('subcategories.html', tables = tables, >> title='Manage sub Categories', form=form, records = records.items, >> next_url = next_url, prev_url = prev_url) >> >> >> >> I cannot work how to get the category ID. If I use validate or not on any >> fields, it doesn?t produce anything in the flash. The page refreshes and >> leave the content in the field. The database isn?t being updated with the >> new sub_category. All the database relationships are working when I >> manually insert the data into the table via SQLIte3. >> >> >> >> Any thoughts? Have I made myself clear enough? >> >> >> >> Sean >> >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Mon Aug 5 10:49:50 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Mon, 5 Aug 2019 09:49:50 -0500 Subject: [Flask] Build a drop down from dictionary Message-ID: Forgive my ignorance, still trying to learn this stuff. I have the following test code: Template: I have a dictionary like: { "First Link": "https:/.....etc...", "Second Link": "https:/....", "third Link:": "https:....." (and so on ... } I would like to replace the From linux4ms at gmail.com Mon Aug 5 12:12:46 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Mon, 5 Aug 2019 11:12:46 -0500 Subject: [Flask] Hmmm ... not feeling the love here ... Message-ID: https://www.quora.com/What-are-the-downsides-of-Pythons-Flask Not my feelings, and definitely strongly disagree on many of this post ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From unai at sysbible.org Mon Aug 5 12:49:29 2019 From: unai at sysbible.org (Unai Rodriguez) Date: Mon, 05 Aug 2019 18:49:29 +0200 Subject: [Flask] Hmmm ... not feeling the love here ... In-Reply-To: References: Message-ID: In line with Quora's content... More clickbait than really a source of knowledge IMHO -- unai On Mon, Aug 5, 2019, at 6:13 PM, Ben Duncan wrote: > https://www.quora.com/What-are-the-downsides-of-Pythons-Flask > > Not my feelings, and definitely strongly disagree on many of this post ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Mon Aug 5 13:10:21 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Mon, 5 Aug 2019 12:10:21 -0500 Subject: [Flask] Hmmm ... not feeling the love here ... In-Reply-To: References: Message-ID: ? *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Mon, Aug 5, 2019 at 11:50 AM Unai Rodriguez wrote: > In line with Quora's content... More clickbait than really a source of > knowledge IMHO > > -- unai > > > On Mon, Aug 5, 2019, at 6:13 PM, Ben Duncan wrote: > > https://www.quora.com/What-are-the-downsides-of-Pythons-Flask > > Not my feelings, and definitely strongly disagree on many of this post ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tamasiaina at gmail.com Mon Aug 5 13:12:01 2019 From: tamasiaina at gmail.com (Jonathan Chen) Date: Mon, 5 Aug 2019 11:12:01 -0600 Subject: [Flask] Hmmm ... not feeling the love here ... In-Reply-To: References: Message-ID: Sorry .... I just replied to it. I know I shouldn't, but I did. I'm adding an answer as well. ~Jonathan C. On Mon, Aug 5, 2019 at 11:11 AM Ben Duncan wrote: > ? > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > > > On Mon, Aug 5, 2019 at 11:50 AM Unai Rodriguez wrote: > >> In line with Quora's content... More clickbait than really a source of >> knowledge IMHO >> >> -- unai >> >> >> On Mon, Aug 5, 2019, at 6:13 PM, Ben Duncan wrote: >> >> https://www.quora.com/What-are-the-downsides-of-Pythons-Flask >> >> Not my feelings, and definitely strongly disagree on many of this post ... >> >> *Ben Duncan* >> DBA / Chief Software Architect >> Mississippi State Supreme Court >> Electronic Filing Division >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask >> > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Mon Aug 5 14:28:47 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Mon, 5 Aug 2019 14:28:47 -0400 Subject: [Flask] Build a drop down from dictionary In-Reply-To: References: Message-ID: depends if you are in Py2 or Py3 https://stackoverflow.com/questions/13998492/when-should-iteritems-be-used-instead-of-items https://jinja.palletsprojects.com/en/2.10.x/templates/#for Is the dict created as a literal, or generated dynamically? Using a tuple/list of tuples/lists might be easier. On Mon, Aug 5, 2019 at 10:51 AM Ben Duncan wrote: > Forgive my ignorance, still trying to learn this stuff. > > I have the following test code: > > Template: > > > > I have a dictionary like: > { "First Link": "https:/.....etc...", "Second Link": "https:/....", "third > Link:": "https:....." (and so on ... } > > I would like to replace the href shows the > URL. How do I go about doing this ? > > Thanks ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adamenglander at yahoo.com Mon Aug 5 22:07:12 2019 From: adamenglander at yahoo.com (Adam Englander) Date: Mon, 5 Aug 2019 19:07:12 -0700 Subject: [Flask] Flask Digest, Vol 50, Issue 3 In-Reply-To: References: Message-ID: <9A03BA82-95EA-4AAC-B7CB-3C8B5665474D@yahoo.com> This should help: https://jinja.palletsprojects.com/en/2.10.x/templates/#variables Adam Englander Sent from my iPhone > On Aug 5, 2019, at 9:00 AM, flask-request at python.org wrote: > > Send Flask mailing list submissions to > flask at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/flask > or, via email, send a message with subject or body 'help' to > flask-request at python.org > > You can reach the person managing the list at > flask-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Flask digest..." > > > Today's Topics: > > 1. Build a drop down from dictionary (Ben Duncan) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 5 Aug 2019 09:49:50 -0500 > From: Ben Duncan > To: Flask User Groups > Subject: [Flask] Build a drop down from dictionary > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Forgive my ignorance, still trying to learn this stuff. > > I have the following test code: > > Template: > > > > I have a dictionary like: > { "First Link": "https:/.....etc...", "Second Link": "https:/....", "third > Link:": "https:....." (and so on ... } > > I would like to replace the href shows the > URL. How do I go about doing this ? > > Thanks ... > > *Ben Duncan* > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > ------------------------------ > > End of Flask Digest, Vol 50, Issue 3 > ************************************ -------------- next part -------------- An HTML attachment was scrubbed... URL: From paradox2005 at gmail.com Tue Aug 6 04:09:50 2019 From: paradox2005 at gmail.com (Adil Hasan) Date: Tue, 6 Aug 2019 09:09:50 +0100 Subject: [Flask] Hmmm ... not feeling the love here ... In-Reply-To: References: Message-ID: <20190806080949.GH4004@parsnip> Hello, I have written a few apps using Flask. For me where flask wins is in the fact that it is minimal and is not opinionated. I use Flask to write a REST API and then I write the front-end in javascript and HTML. For a javascript library I tried Angular, but found it difficult to use (could be I am not smart enough to use it) and the migration from 1.x to 2.x disappointed me. I have dabbled with Aurelia and am looking at Elm. I have avoided using python to create HTML pages based on my experience of trying to support a Java-based web application (unless you know Java well modifying web front-ends generated by Java is not easy). I feel that templates have limitations. So, for me Django is far too heavyweight. Slighty more heretical. I even avoid ORMs. I have found a config file with simple SQL is much easier to maintain. I used this approach for a project many years ago and provided the python code to some folks who used it and updated it over something like 10 years. But, that's my personal experience. Of course, most of this is a matter of opinion and different people have different viewpoints. hth adil On Mon, Aug 05, 2019 at 11:12:01AM -0600, Jonathan Chen wrote: > Sorry .... I just replied to it. I know I shouldn't, but I did. I'm adding > an answer as well. > > ~Jonathan C. > > > On Mon, Aug 5, 2019 at 11:11 AM Ben Duncan wrote: > > > ? > > *Ben Duncan* > > DBA / Chief Software Architect > > Mississippi State Supreme Court > > Electronic Filing Division > > > > > > On Mon, Aug 5, 2019 at 11:50 AM Unai Rodriguez wrote: > > > >> In line with Quora's content... More clickbait than really a source of > >> knowledge IMHO > >> > >> -- unai > >> > >> > >> On Mon, Aug 5, 2019, at 6:13 PM, Ben Duncan wrote: > >> > >> https://www.quora.com/What-are-the-downsides-of-Pythons-Flask > >> > >> Not my feelings, and definitely strongly disagree on many of this post ... > >> > >> *Ben Duncan* > >> DBA / Chief Software Architect > >> Mississippi State Supreme Court > >> Electronic Filing Division > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > >> > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > >> > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From linux4ms at gmail.com Tue Aug 6 07:07:29 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Tue, 6 Aug 2019 06:07:29 -0500 Subject: [Flask] Hmmm ... not feeling the love here ... In-Reply-To: <20190806080949.GH4004@parsnip> References: <20190806080949.GH4004@parsnip> Message-ID: Thanks adil ... I've switched from using web2py because of the very same thing. Don't get me wrong, I like web2py, but it is "Batteries" included and when I went to colour outside the box, well, it just did not go well. I want, but still lets me "colour" outside the box ? *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Tue, Aug 6, 2019 at 3:09 AM Adil Hasan wrote: > Hello, > > I have written a few apps using Flask. For me where flask wins is in the > fact that it is minimal and is not opinionated. > > I use Flask to write a REST API and then I write the front-end in > javascript and HTML. For a javascript library I tried Angular, but found > it difficult to use (could be I am not smart enough to use it) and the > migration from 1.x to 2.x disappointed me. I have dabbled with Aurelia > and am looking at Elm. > > I have avoided using python to create HTML pages based on my experience > of trying to support a Java-based web application (unless you know Java > well modifying web front-ends generated by Java is not easy). I feel > that templates have limitations. So, for me Django is far too > heavyweight. > > Slighty more heretical. I even avoid ORMs. I have found a config file > with simple SQL is much easier to maintain. I used this approach for a > project many years ago and provided the python code to some folks who > used it and updated it over something like 10 years. But, that's my > personal experience. > > Of course, most of this is a matter of opinion and different people have > different viewpoints. > > hth > adil > > > On Mon, Aug 05, 2019 at 11:12:01AM -0600, Jonathan Chen wrote: > > Sorry .... I just replied to it. I know I shouldn't, but I did. I'm > adding > > an answer as well. > > > > ~Jonathan C. > > > > > > On Mon, Aug 5, 2019 at 11:11 AM Ben Duncan wrote: > > > > > ? > > > *Ben Duncan* > > > DBA / Chief Software Architect > > > Mississippi State Supreme Court > > > Electronic Filing Division > > > > > > > > > On Mon, Aug 5, 2019 at 11:50 AM Unai Rodriguez > wrote: > > > > > >> In line with Quora's content... More clickbait than really a source of > > >> knowledge IMHO > > >> > > >> -- unai > > >> > > >> > > >> On Mon, Aug 5, 2019, at 6:13 PM, Ben Duncan wrote: > > >> > > >> https://www.quora.com/What-are-the-downsides-of-Pythons-Flask > > >> > > >> Not my feelings, and definitely strongly disagree on many of this > post ... > > >> > > >> *Ben Duncan* > > >> DBA / Chief Software Architect > > >> Mississippi State Supreme Court > > >> Electronic Filing Division > > >> _______________________________________________ > > >> Flask mailing list > > >> Flask at python.org > > >> https://mail.python.org/mailman/listinfo/flask > > >> > > >> _______________________________________________ > > >> Flask mailing list > > >> Flask at python.org > > >> https://mail.python.org/mailman/listinfo/flask > > >> > > > _______________________________________________ > > > Flask mailing list > > > Flask at python.org > > > https://mail.python.org/mailman/listinfo/flask > > > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Tue Aug 6 13:19:51 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Tue, 6 Aug 2019 12:19:51 -0500 Subject: [Flask] AppBuilder Message-ID: Anyone using the Flask AppBuilder ? If so, what do you think? Thanks ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Tue Aug 6 13:40:48 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Tue, 6 Aug 2019 13:40:48 -0400 Subject: [Flask] AppBuilder In-Reply-To: References: Message-ID: What/where is it? On Tue, Aug 6, 2019 at 1:20 PM Ben Duncan wrote: > > > Anyone using the Flask AppBuilder ? > If so, what do you think? > > Thanks ... > > > Ben Duncan > DBA / Chief Software Architect > Mississippi State Supreme Court > Electronic Filing Division > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From linux4ms at gmail.com Tue Aug 6 15:05:57 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Tue, 6 Aug 2019 14:05:57 -0500 Subject: [Flask] AppBuilder In-Reply-To: References: Message-ID: https://flask-appbuilder.readthedocs.io/en/latest/api.html *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division On Tue, Aug 6, 2019 at 12:41 PM Corey Boyle wrote: > What/where is it? > > > On Tue, Aug 6, 2019 at 1:20 PM Ben Duncan wrote: > > > > > > Anyone using the Flask AppBuilder ? > > If so, what do you think? > > > > Thanks ... > > > > > > Ben Duncan > > DBA / Chief Software Architect > > Mississippi State Supreme Court > > Electronic Filing Division > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhysnm1964 at gmail.com Wed Aug 7 08:27:25 2019 From: mhysnm1964 at gmail.com (mhysnm1964 at gmail.com) Date: Wed, 7 Aug 2019 22:27:25 +1000 Subject: [Flask] Query in relation to having two forms on the same page and sorting tables. Message-ID: <054101d54d1b$798b3680$6ca1a380$@gmail.com> All, I am using flask_wtf to build my forms. I am trying to create a page with two separate forms. One form is for searching the database. The 2nd form is in my table to sort the columns. As I wanted to use buttons. So I am not 100% sure if I have gone in the right direction with my design. What I am finding is only one occurrence of the validate_on_submit() is being set to true from the form objects. In other words, the 2nd instance of the form on the web page is always setting the submit validate state to True. The first instance of the form never get set to True. I have the 2nd instance in a sub-template. the questions I have: 1. How can I use buttons without using the form tag? 2. Can I use links to perform the sort in the table and if so, how? As I am sorting the current table. I would have to reload the page and include the URL some form of values to indicate what field to sort on. This is the bit I do not know how. 3. Can you have two forms on the same page and get validate_on_submit() methods to correctly behave as I outlined above. Code extracts showing what is not working. View/Routes code first: @app.route('/', methods=['GET', 'POST']) @app.route('/index', methods=['GET', 'POST']) def index(): tables = Accounts.query.all() form = SearchForm() sort_form = SortForm() print ("validate submit", sort_form.validate_on_submit(), form.validate_on_submit()) if form.validate_on_submit(): # code here never gets run. elif sort_form.validate_on_submit (): # code here always gets run regardless what button is click. else: records = Transactions.query.order_by(Transactions.subcategory_id, Transactions.transactiondate.desc()) page = request.args.get('page', 1, type=int) records = records.paginate(page, app.config['POSTS_PER_PAGE'], False) next_url = url_for('index', page=records.next_num) if records.has_next else None prev_url = url_for('index', page=records.prev_num) if records.has_prev else None return render_template('index.html', title='Budget Program Main Page', records = records.items, tables = tables, account = 'all Transactions', prev_url = prev_url, next_url = next_url, form = form, sort_form = sort_form) Now for the form.py: class SearchForm (FlaskForm): subcategory = SelectField('Select Sub Category', choices= [(c.id, c.subcategory) for c in SubCategories.query.order_by('subcategory')], default=1) search = StringField('Description') submit = SubmitField('Search') class SortForm (FlaskForm): sortby_date = SubmitField('Sort By date') sortby_description = SubmitField('sort by Description') sortby_subcategory = SubmitField('sort by Subcategory') sortby_category = SubmitField('sort by Category') Now for the Index file: {% extends "base.html" %} {% block content %}

{{ account }}

{{ form.hidden_tag() }} {{ form.subcategory.label }} {{ form.subcategory(rows=10) }}
{{ form.search.label }}
{{ form.search(size=64) }}
{% for error in form.search.errors %} [{{ error }}] {% endfor %}

{{ form.submit() }}

{% include 'tables.html' %} {% endblock %} Now for the extracted sub-template called tables:
{% if prev_url %} Previous Records {% endif %} {% if next_url %} Next Records {% endif %} {{ form.hidden_tag() }} {% for row in records %} Any ideas? If I could use links than buttons, this would e okay. -------------- next part -------------- An HTML attachment was scrubbed... URL: From coreybrett at gmail.com Wed Aug 7 09:47:33 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Wed, 7 Aug 2019 09:47:33 -0400 Subject: [Flask] Query in relation to having two forms on the same page and sorting tables. In-Reply-To: <054101d54d1b$798b3680$6ca1a380$@gmail.com> References: <054101d54d1b$798b3680$6ca1a380$@gmail.com> Message-ID: In short, your code has to determine which form is being submitted and which button has been used. https://stackoverflow.com/questions/18290142/multiple-forms-in-a-single-page-using-flask-and-wtforms On Wed, Aug 7, 2019 at 8:27 AM wrote: > > All, > > > > I am using flask_wtf to build my forms. I am trying to create a page with two separate forms. One form is for searching the database. The 2nd form is in my table to sort the columns. As I wanted to use buttons. So I am not 100% sure if I have gone in the right direction with my design. What I am finding is only one occurrence of the validate_on_submit() is being set to true from the form objects. In other words, the 2nd instance of the form on the web page is always setting the submit validate state to True. The first instance of the form never get set to True. I have the 2nd instance in a sub-template. the questions I have: > > How can I use buttons without using the form tag? > Can I use links to perform the sort in the table and if so, how? As I am sorting the current table. I would have to reload the page and include the URL some form of values to indicate what field to sort on. This is the bit I do not know how. > Can you have two forms on the same page and get validate_on_submit() methods to correctly behave as I outlined above. > > Code extracts showing what is not working. View/Routes code first: > > > > @app.route('/', methods=['GET', 'POST']) > > @app.route('/index', methods=['GET', 'POST']) > > def index(): > > tables = Accounts.query.all() > > form = SearchForm() > > sort_form = SortForm() > > print ("validate submit", sort_form.validate_on_submit(), form.validate_on_submit()) > > if form.validate_on_submit(): > > # code here never gets run. > > elif sort_form.validate_on_submit (): > > # code here always gets run regardless what button is click. > > else: > > records = Transactions.query.order_by(Transactions.subcategory_id, Transactions.transactiondate.desc()) > > page = request.args.get('page', 1, type=int) > > records = records.paginate(page, app.config['POSTS_PER_PAGE'], False) > > next_url = url_for('index', page=records.next_num) if records.has_next else None > > prev_url = url_for('index', page=records.prev_num) if records.has_prev else None > > return render_template('index.html', title='Budget Program Main Page', records = records.items, tables = tables, account = 'all Transactions', prev_url = prev_url, next_url = next_url, form = form, sort_form = sort_form) > > > > Now for the form.py: > > > > class SearchForm (FlaskForm): > > subcategory = SelectField('Select Sub Category', choices= [(c.id, c.subcategory) for c in SubCategories.query.order_by('subcategory')], default=1) > > search = StringField('Description') > > submit = SubmitField('Search') > > > > > > class SortForm (FlaskForm): > > sortby_date = SubmitField('Sort By date') > > sortby_description = SubmitField('sort by Description') > > sortby_subcategory = SubmitField('sort by Subcategory') > > sortby_category = SubmitField('sort by Category') > > > > > > Now for the Index file: > > > > {% extends "base.html" %} > > > > {% block content %} > >

{{ account }}

> >
> > {{ form.hidden_tag() }} > > {{ form.subcategory.label }} > > {{ form.subcategory(rows=10) }}
> > {{ form.search.label }}
> > {{ form.search(size=64) }}
> > {% for error in form.search.errors %} > > [{{ error }}] > > {% endfor %} > >

> >

{{ form.submit() }}

> > > > {% include 'tables.html' %} > > {% endblock %} > > > > Now for the extracted sub-template called tables: > > > > > >
> > {% if prev_url %} > > Previous Records > > {% endif %} > > {% if next_url %} > > Next Records > > {% endif %} > >
Records
Account Name Account Number {{ sort_form.sortby_date() }} {{ sort_form.sortby_description () }} Amount {{ sort_form.sortby_category() }} {{ sort_form.sortby_subcategory () }}
> > > > > > {{ form.hidden_tag() }} > > > > > > > > > > > > > > > > > > > > > > {% for row in records %} > > > > Any ideas? If I could use links than buttons, this would e okay. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From mhysnm1964 at gmail.com Wed Aug 7 18:58:30 2019 From: mhysnm1964 at gmail.com (mhysnm1964 at gmail.com) Date: Thu, 8 Aug 2019 08:58:30 +1000 Subject: [Flask] Query in relation to having two forms on the same page and sorting tables. In-Reply-To: References: <054101d54d1b$798b3680$6ca1a380$@gmail.com> Message-ID: <01f401d54d73$a2d69f90$e883deb0$@gmail.com> Thanks, I see I was missing the form.submit.data in my if test. -----Original Message----- From: Corey Boyle Sent: Wednesday, 7 August 2019 11:48 PM To: Sean Murphy Cc: flask Subject: Re: [Flask] Query in relation to having two forms on the same page and sorting tables. In short, your code has to determine which form is being submitted and which button has been used. https://stackoverflow.com/questions/18290142/multiple-forms-in-a-single-page-using-flask-and-wtforms On Wed, Aug 7, 2019 at 8:27 AM wrote: > > All, > > > > I am using flask_wtf to build my forms. I am trying to create a page with two separate forms. One form is for searching the database. The 2nd form is in my table to sort the columns. As I wanted to use buttons. So I am not 100% sure if I have gone in the right direction with my design. What I am finding is only one occurrence of the validate_on_submit() is being set to true from the form objects. In other words, the 2nd instance of the form on the web page is always setting the submit validate state to True. The first instance of the form never get set to True. I have the 2nd instance in a sub-template. the questions I have: > > How can I use buttons without using the form tag? > Can I use links to perform the sort in the table and if so, how? As I am sorting the current table. I would have to reload the page and include the URL some form of values to indicate what field to sort on. This is the bit I do not know how. > Can you have two forms on the same page and get validate_on_submit() methods to correctly behave as I outlined above. > > Code extracts showing what is not working. View/Routes code first: > > > > @app.route('/', methods=['GET', 'POST']) > > @app.route('/index', methods=['GET', 'POST']) > > def index(): > > tables = Accounts.query.all() > > form = SearchForm() > > sort_form = SortForm() > > print ("validate submit", sort_form.validate_on_submit(), > form.validate_on_submit()) > > if form.validate_on_submit(): > > # code here never gets run. > > elif sort_form.validate_on_submit (): > > # code here always gets run regardless what button is click. > > else: > > records = > Transactions.query.order_by(Transactions.subcategory_id, > Transactions.transactiondate.desc()) > > page = request.args.get('page', 1, type=int) > > records = records.paginate(page, app.config['POSTS_PER_PAGE'], > False) > > next_url = url_for('index', page=records.next_num) if > records.has_next else None > > prev_url = url_for('index', page=records.prev_num) if > records.has_prev else None > > return render_template('index.html', title='Budget Program Main > Page', records = records.items, tables = tables, account = 'all > Transactions', prev_url = prev_url, next_url = next_url, form = form, > sort_form = sort_form) > > > > Now for the form.py: > > > > class SearchForm (FlaskForm): > > subcategory = SelectField('Select Sub Category', choices= [(c.id, > c.subcategory) for c in SubCategories.query.order_by('subcategory')], > default=1) > > search = StringField('Description') > > submit = SubmitField('Search') > > > > > > class SortForm (FlaskForm): > > sortby_date = SubmitField('Sort By date') > > sortby_description = SubmitField('sort by Description') > > sortby_subcategory = SubmitField('sort by Subcategory') > > sortby_category = SubmitField('sort by Category') > > > > > > Now for the Index file: > > > > {% extends "base.html" %} > > > > {% block content %} > >

{{ account }}

> >
> > {{ form.hidden_tag() }} > > {{ form.subcategory.label }} > > {{ form.subcategory(rows=10) }}
> > {{ form.search.label }}
> > {{ form.search(size=64) }}
> > {% for error in form.search.errors %} > > [{{ error }}] > > {% endfor %} > >

> >

{{ form.submit() }}

> > > > {% include 'tables.html' %} > > {% endblock %} > > > > Now for the extracted sub-template called tables: > > > > > >
> > {% if prev_url %} > > Previous Records > > {% endif %} > > {% if next_url %} > > Next Records > > {% endif %} > >
Records
Account NameAccount Number {{ sort_form.sortby_date() }} {{ sort_form.sortby_description () }} Amount {{ sort_form.sortby_category() }} {{ sort_form.sortby_subcategory () }}
> > > > > > {{ form.hidden_tag() }} > > > > > > > > > > > > > > > > > > > > > > {% for row in records %} > > > > Any ideas? If I could use links than buttons, this would e okay. > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From linux4ms at gmail.com Thu Aug 8 07:07:44 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Thu, 8 Aug 2019 06:07:44 -0500 Subject: [Flask] PyDal Connector Message-ID: Has anyone adapted PyDal from web2py group as the database connector for Flask? It has been spun off to a separate library ... I really prefer it to SQLalchemy ORM (OR any ORM for that matter) See: https://pypi.org/project/pydal/ http://zetcode.com/python/pydal/ ...etc.. Again, thanks ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.martell at gmail.com Fri Aug 9 15:09:48 2019 From: larry.martell at gmail.com (Larry Martell) Date: Fri, 9 Aug 2019 15:09:48 -0400 Subject: [Flask] Connecting to 2 servers Message-ID: I have a flask app I inherited. It connects to a MySQL server and I need to add a second connection to a MS SQL server. The connection to the MySQL server was done like this: engine = create_engine_from_str(connect_string) factory = scoped_session(sessionmaker(bind=engine)) factory.configure(bind=engine) I added a second connection: m_engine = create_engine_from_str(m_connect_string) m_factory = scoped_session(sessionmaker(bind=m_engine)) m_factory.configure(bind=m_engine) But when I try any use the second connection it fails: sqlalchemy.exc.InterfaceError: (pyodbc.InterfaceError) ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)') What am I doing wrong? From coreybrett at gmail.com Sun Aug 11 12:19:51 2019 From: coreybrett at gmail.com (Corey Boyle) Date: Sun, 11 Aug 2019 12:19:51 -0400 Subject: [Flask] Extensions directory Message-ID: What happened to the Flask Extensions directory? From mhysnm1964 at gmail.com Mon Aug 12 08:45:32 2019 From: mhysnm1964 at gmail.com (mhysnm1964 at gmail.com) Date: Mon, 12 Aug 2019 22:45:32 +1000 Subject: [Flask] flask tables with relationship tables. Message-ID: <009b01d5510b$d5c49ce0$814dd6a0$@gmail.com> All, I am using flask_tables and flask_sqlalchemy to generate the database. I want to know how I can populate the class you have to create for flask_tables with an relational database. The model I am using is: class Categories(db.Model): id = db.Column(db.Integer, primary_key=True) category = db.Column(db.String(64), index=True, unique=True) subcategories = db.relationship('SubCategories', backref='categories', lazy='dynamic') def __repr__(self): return ''.format(self.category) class SubCategories(db.Model): id = db.Column(db.Integer, primary_key=True) subcategory = db.Column(db.String(80), index=True, unique=True) category_id = db.Column(db.Integer, db.ForeignKey('categories.id')) transactions = db.relationship('Transactions', backref='sub_categories', lazy='dynamic') def __repr__(self): return ''.format(self.subcategory) class Transactions (db.Model): id = db.Column(db.Integer, primary_key=True) transactiondate = db.Column(db.Date, index=True, nullable=False) description = db.Column(db.String(80), nullable=False) amount = db.Column(db.Float, nullable=False) subcategory_id = db.Column(db.Integer, db.ForeignKey('sub_categories.id')) account_no = db.Column(db.Integer, db.ForeignKey('accounts.account_number')) The queries I have used are: Records = Transactions.query.all() Records = Transactions.query.join(SubCategories).join(Categories).all() If I use records[0].SubCategories.Categories.category in the flask shell. I get the category value. But I get nothing when I use the flask_table. Col(SubCategories.Categories.category) in the table class. Not sure what I am doing wrong. As I cannot find any examples for this module with relational databases. I am assuming everything between the Col(.) is the field of the database. Does anyone have examples that I can have a look at using this module? AS it appears it has a built in sort method for the table. The other question flask_sqlalchemy has the ability of pagination. How can I get this to work with Flask_table? Do I just feed it a sqlalchemy object that is generated from the pagination process. Any help or tips would be welcomed. New at all this and still trying to get my head around everything. I do have many more questions. But they can wait for now. Note, Either method of query I have shown generates the same result when I use it in the flask shell. def __repr__(self): return ''.format(self.description) -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.martell at gmail.com Mon Aug 12 10:27:48 2019 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 12 Aug 2019 10:27:48 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: References: Message-ID: On Fri, Aug 9, 2019 at 5:30 PM Dennis Lee Bieber wrote: > > On Fri, 9 Aug 2019 15:09:48 -0400, Larry Martell > declaimed the > following: > > > > >What am I doing wrong? > > Well... Among other things, withholding information... > > What is the connection string? And have you TESTED the connection > string without the overhead of SQLAlchemy? Yes, I can connect to the DB outside of the flask app. Here is the connection string: mssql+pyodbc://user:password at host/DSE_Rep.rep?driver=SQL+Server+Native+Client+10.0 I have never used flask/SQLAlchemy with MS SQL before - could the DSE_Rep.rep be the issue? How can I specify that hierarchy? From larry.martell at gmail.com Mon Aug 12 13:18:24 2019 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 12 Aug 2019 13:18:24 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> Message-ID: On Mon, Aug 12, 2019 at 11:41 AM Dennis Lee Bieber wrote: > > On Mon, 12 Aug 2019 10:27:48 -0400, Larry Martell > declaimed the > following: > > >Yes, I can connect to the DB outside of the flask app. Here is the > >connection string: > > > >mssql+pyodbc://user:password at host/DSE_Rep.rep?driver=SQL+Server+Native+Client+10.0 > > > > That looks nothing like a common connection string. Not even one using > a DSN (thereby putting the actual connection specification external to the > string). It looks more like a URL that might be used in a web browser. > > I've always seen them as semi-colon separated arguments... cf: > https://github.com/mkleehammer/pyodbc/wiki/Connecting-to-SQL-Server-from-Windows > https://docs.microsoft.com/en-us/sql/connect/python/pyodbc/step-3-proof-of-concept-connecting-to-sql-using-pyodbc?view=sql-server-2017 > https://www.connectionstrings.com/sql-server/ > > > >I have never used flask/SQLAlchemy with MS SQL before - could the > >DSE_Rep.rep be the issue? How can I specify that hierarchy? > > HOWEVER, looking at > https://docs.sqlalchemy.org/en/13/dialects/mssql.html#module-sqlalchemy.dialects.mssql.pyodbc > does display something of the nature you show. I'd probably prefer using > either > https://docs.sqlalchemy.org/en/13/dialects/mssql.html#pass-through-exact-pyodbc-string > (though there is a problem in that urllib has changed... one has to import > urllib.parse explicitly in Python 3.x) > > or > https://docs.sqlalchemy.org/en/13/dialects/mssql.html#dsn-connections > format > > If I interpret it, you are using the form > https://docs.sqlalchemy.org/en/13/dialects/mssql.html#hostname-connections > where > DSE_rep.rep > is the DATABASE NAME. As I interpret > https://docs.microsoft.com/en-us/sql/relational-databases/databases/database-identifiers?view=sql-server-2017 > embedded periods are not allowed in a bare database name. You would have to > use a delimited name, which means putting " or [ ] around the name. Don't > know how SQLAlchemy would handle these variations: > > mssql+pyodbc://user:password at host/"DSE_Rep.rep"?driver=SQL+Server+Native+Client+10.0 > > mssql+pyodbc://user:password at host/[DSE_Rep.rep]?driver=SQL+Server+Native+Client+10.0 > > (Obviously, if using ", you'll have to use ' for the full string -- I'd > find that a pain as I instinctively use " for string literals ) > > > The reason I'd favor what SQLAlchemy calls "pass through exact..." is > that this is the exact string you'd use if coding a direct pyodbc > connection -- or would be the contents defined in a DSN set-up externally. > And that is what I meant by "can you connect" -- using the exact connection > string but bypassing SQLAlchemy. The string you are using requires > SQLAlchemy to parse and format into the end-use connection string -- > meaning two points of potential failure: SQLAlchemy parsing to pyodbc, and > pyodbc to SQL Server. I changed it to use the 'pass-through-exact-pyodbc-string' but got the same error. Then I thought maybe the driver is not installed. So I followed the instructions here: https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 and installed it and changed my driver string to ODBC Driver 17 for SQL Server and now I get: Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found but it is there: # ls -l /usr/local/lib/libmsodbcsql.17.dylib -r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib From paradox2005 at gmail.com Mon Aug 12 14:59:24 2019 From: paradox2005 at gmail.com (Adil Hasan) Date: Mon, 12 Aug 2019 19:59:24 +0100 Subject: [Flask] Connecting to 2 servers In-Reply-To: References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> Message-ID: <20190812185923.GS21042@parsnip> Hello, Perhaps you could try to set the LD_LIBRARY_FLAG environmental variable. You may already have it set, so you just need to append the path at the end. If you're using bash: export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} That I think should allow the application to find the library path. hth adil On Mon, Aug 12, 2019 at 02:13:36PM -0400, Dennis Lee Bieber wrote: > On Mon, 12 Aug 2019 13:18:24 -0400, Larry Martell > declaimed the > following: > > > > >I changed it to use the 'pass-through-exact-pyodbc-string' but got the > >same error. Then I thought maybe the driver is not installed. So I > >followed the instructions here: > > > >https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 > > > >and installed it and changed my driver string to ODBC Driver 17 for > >SQL Server and now I get: > > > >Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found > > > >but it is there: > > > ># ls -l /usr/local/lib/libmsodbcsql.17.dylib > >-r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib > > We're past my level of expertise (in truth, Google was the source for > everything in my previous post). Best I can come up with might be related > to > > https://linux.die.net/man/8/ldconfig > > Does > ldconfig -p > list the file? If not... is /usr/local/lib somewhere in /etc/ld.so.conf (or > any subfiles referenced)? The Debian on Windows seems to have it > included... > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf > include /etc/ld.so.conf.d/*.conf > > wulfraed at ElusiveUnicorn:~$ ls /etc/ld.so.conf.d/ > libc.conf x86_64-linux-gnu.conf > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf.d/*.conf > # libc default configuration > /usr/local/lib > # Multiarch support > /lib/x86_64-linux-gnu > /usr/lib/x86_64-linux-gnu > wulfraed at ElusiveUnicorn:~$ > > Even with it (the directory) there, you may need to rebuild cache by > running ldconfig > > > -- > Wulfraed Dennis Lee Bieber AF6VN > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From larry.martell at gmail.com Mon Aug 12 15:13:15 2019 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 12 Aug 2019 15:13:15 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> Message-ID: On Mon, Aug 12, 2019 at 2:14 PM Dennis Lee Bieber wrote: > > On Mon, 12 Aug 2019 13:18:24 -0400, Larry Martell > declaimed the > following: > > > > >I changed it to use the 'pass-through-exact-pyodbc-string' but got the > >same error. Then I thought maybe the driver is not installed. So I > >followed the instructions here: > > > >https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 > > > >and installed it and changed my driver string to ODBC Driver 17 for > >SQL Server and now I get: > > > >Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found > > > >but it is there: > > > ># ls -l /usr/local/lib/libmsodbcsql.17.dylib > >-r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib > > We're past my level of expertise (in truth, Google was the source for > everything in my previous post). Best I can come up with might be related > to > > https://linux.die.net/man/8/ldconfig > > Does > ldconfig -p > list the file? No. > If not... is /usr/local/lib somewhere in /etc/ld.so.conf (or > any subfiles referenced)? The Debian on Windows seems to have it > included... > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf > include /etc/ld.so.conf.d/*.conf > > wulfraed at ElusiveUnicorn:~$ ls /etc/ld.so.conf.d/ > libc.conf x86_64-linux-gnu.conf > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf.d/*.conf > # libc default configuration > /usr/local/lib > # Multiarch support > /lib/x86_64-linux-gnu > /usr/lib/x86_64-linux-gnu > wulfraed at ElusiveUnicorn:~$ > > Even with it (the directory) there, you may need to rebuild cache by > running ldconfig This is Amazon Linux # ls /etc/ld.so.conf.d/ kernel-4.14.123-86.109.amzn1.x86_64.conf kernel-4.14.133-88.105.amzn1.x86_64.conf kernel-4.14.133-88.112.amzn1.x86_64.conf # cat /etc/ld.so.conf.d/* # This directive teaches ldconfig to search in nosegneg subdirectories # and cache the DSOs there with extra bit 0 set in their hwcap match # fields. In Xen guest kernels, the vDSO tells the dynamic linker to # search in nosegneg subdirectories and to match this extra hwcap bit # in the ld.so.cache file. hwcap 1 nosegneg # This directive teaches ldconfig to search in nosegneg subdirectories # and cache the DSOs there with extra bit 0 set in their hwcap match # fields. In Xen guest kernels, the vDSO tells the dynamic linker to # search in nosegneg subdirectories and to match this extra hwcap bit # in the ld.so.cache file. hwcap 1 nosegneg # This directive teaches ldconfig to search in nosegneg subdirectories # and cache the DSOs there with extra bit 0 set in their hwcap match # fields. In Xen guest kernels, the vDSO tells the dynamic linker to # search in nosegneg subdirectories and to match this extra hwcap bit # in the ld.so.cache file. hwcap 1 nosegneg If I run ldconfig -v I can see it search in /lib: /lib64: /usr/lib: /usr/lib64: I tried symlinking /usr/local/lib/libmsodbcsql.17.dylib to /usr/lib but it still did not pick it up. From larry.martell at gmail.com Mon Aug 12 15:53:28 2019 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 12 Aug 2019 15:53:28 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: <20190812185923.GS21042@parsnip> References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> <20190812185923.GS21042@parsnip> Message-ID: On Mon, Aug 12, 2019 at 3:00 PM Adil Hasan wrote: > > Hello, > Perhaps you could try to set the LD_LIBRARY_FLAG environmental variable. > You may already have it set, so you just need to append the path at the > end. If you're using bash: > > export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} > > That I think should allow the application to find the library path. That also did not work. > On Mon, Aug 12, 2019 at 02:13:36PM -0400, Dennis Lee Bieber wrote: > > On Mon, 12 Aug 2019 13:18:24 -0400, Larry Martell > > declaimed the > > following: > > > > > > > >I changed it to use the 'pass-through-exact-pyodbc-string' but got the > > >same error. Then I thought maybe the driver is not installed. So I > > >followed the instructions here: > > > > > >https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 > > > > > >and installed it and changed my driver string to ODBC Driver 17 for > > >SQL Server and now I get: > > > > > >Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found > > > > > >but it is there: > > > > > ># ls -l /usr/local/lib/libmsodbcsql.17.dylib > > >-r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib > > > > We're past my level of expertise (in truth, Google was the source for > > everything in my previous post). Best I can come up with might be related > > to > > > > https://linux.die.net/man/8/ldconfig > > > > Does > > ldconfig -p > > list the file? If not... is /usr/local/lib somewhere in /etc/ld.so.conf (or > > any subfiles referenced)? The Debian on Windows seems to have it > > included... > > > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf > > include /etc/ld.so.conf.d/*.conf > > > > wulfraed at ElusiveUnicorn:~$ ls /etc/ld.so.conf.d/ > > libc.conf x86_64-linux-gnu.conf > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf.d/*.conf > > # libc default configuration > > /usr/local/lib > > # Multiarch support > > /lib/x86_64-linux-gnu > > /usr/lib/x86_64-linux-gnu > > wulfraed at ElusiveUnicorn:~$ > > > > Even with it (the directory) there, you may need to rebuild cache by > > running ldconfig > > > > > > -- > > Wulfraed Dennis Lee Bieber AF6VN > > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > > > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From paradox2005 at gmail.com Mon Aug 12 16:32:59 2019 From: paradox2005 at gmail.com (Adil Hasan) Date: Mon, 12 Aug 2019 21:32:59 +0100 Subject: [Flask] Connecting to 2 servers In-Reply-To: References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> <20190812185923.GS21042@parsnip> Message-ID: <20190812203258.GT21042@parsnip> Hello, oh. Perhaps this may help: https://stackoverflow.com/questions/34785653/pyodbc-cant-open-the-driver-even-if-it-exists Perhaps there are some other libraries missing. If you try to run ldd against the library it will indicate what is missing? hth adil On Mon, Aug 12, 2019 at 03:53:28PM -0400, Larry Martell wrote: > On Mon, Aug 12, 2019 at 3:00 PM Adil Hasan wrote: > > > > Hello, > > Perhaps you could try to set the LD_LIBRARY_FLAG environmental variable. > > You may already have it set, so you just need to append the path at the > > end. If you're using bash: > > > > export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} > > > > That I think should allow the application to find the library path. > > That also did not work. > > > > On Mon, Aug 12, 2019 at 02:13:36PM -0400, Dennis Lee Bieber wrote: > > > On Mon, 12 Aug 2019 13:18:24 -0400, Larry Martell > > > declaimed the > > > following: > > > > > > > > > > >I changed it to use the 'pass-through-exact-pyodbc-string' but got the > > > >same error. Then I thought maybe the driver is not installed. So I > > > >followed the instructions here: > > > > > > > >https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 > > > > > > > >and installed it and changed my driver string to ODBC Driver 17 for > > > >SQL Server and now I get: > > > > > > > >Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found > > > > > > > >but it is there: > > > > > > > ># ls -l /usr/local/lib/libmsodbcsql.17.dylib > > > >-r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib > > > > > > We're past my level of expertise (in truth, Google was the source for > > > everything in my previous post). Best I can come up with might be related > > > to > > > > > > https://linux.die.net/man/8/ldconfig > > > > > > Does > > > ldconfig -p > > > list the file? If not... is /usr/local/lib somewhere in /etc/ld.so.conf (or > > > any subfiles referenced)? The Debian on Windows seems to have it > > > included... > > > > > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf > > > include /etc/ld.so.conf.d/*.conf > > > > > > wulfraed at ElusiveUnicorn:~$ ls /etc/ld.so.conf.d/ > > > libc.conf x86_64-linux-gnu.conf > > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf.d/*.conf > > > # libc default configuration > > > /usr/local/lib > > > # Multiarch support > > > /lib/x86_64-linux-gnu > > > /usr/lib/x86_64-linux-gnu > > > wulfraed at ElusiveUnicorn:~$ > > > > > > Even with it (the directory) there, you may need to rebuild cache by > > > running ldconfig > > > > > > > > > -- > > > Wulfraed Dennis Lee Bieber AF6VN > > > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > > > > > > _______________________________________________ > > > Flask mailing list > > > Flask at python.org > > > https://mail.python.org/mailman/listinfo/flask > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask From larry.martell at gmail.com Mon Aug 12 16:53:53 2019 From: larry.martell at gmail.com (Larry Martell) Date: Mon, 12 Aug 2019 16:53:53 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: <20190812203258.GT21042@parsnip> References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> <20190812185923.GS21042@parsnip> <20190812203258.GT21042@parsnip> Message-ID: On Mon, Aug 12, 2019 at 4:33 PM Adil Hasan wrote: > > Hello, > > oh. > > Perhaps this may help: > https://stackoverflow.com/questions/34785653/pyodbc-cant-open-the-driver-even-if-it-exists Tried solutions mentioned in that post, no joy. > Perhaps there are some other libraries missing. If you try to run ldd > against the library it will indicate what is missing? # ldd /usr/local/lib/libmsodbcsql.17.dylib not a dynamic executable > > hth > adil > > On Mon, Aug 12, 2019 at 03:53:28PM -0400, Larry Martell wrote: > > On Mon, Aug 12, 2019 at 3:00 PM Adil Hasan wrote: > > > > > > Hello, > > > Perhaps you could try to set the LD_LIBRARY_FLAG environmental variable. > > > You may already have it set, so you just need to append the path at the > > > end. If you're using bash: > > > > > > export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH} > > > > > > That I think should allow the application to find the library path. > > > > That also did not work. > > > > > > > On Mon, Aug 12, 2019 at 02:13:36PM -0400, Dennis Lee Bieber wrote: > > > > On Mon, 12 Aug 2019 13:18:24 -0400, Larry Martell > > > > declaimed the > > > > following: > > > > > > > > > > > > > >I changed it to use the 'pass-through-exact-pyodbc-string' but got the > > > > >same error. Then I thought maybe the driver is not installed. So I > > > > >followed the instructions here: > > > > > > > > > >https://medium.com/@liamfirth/installing-mssql-odbc-driver-17-1-0-1-on-amazon-web-services-linux-9a8febccfe94 > > > > > > > > > >and installed it and changed my driver string to ODBC Driver 17 for > > > > >SQL Server and now I get: > > > > > > > > > >Can't open lib '/usr/local/lib/libmsodbcsql.17.dylib' : file not found > > > > > > > > > >but it is there: > > > > > > > > > ># ls -l /usr/local/lib/libmsodbcsql.17.dylib > > > > >-r--r--r-- 1 root root 2539360 Aug 12 17:06 /usr/local/lib/libmsodbcsql.17.dylib > > > > > > > > We're past my level of expertise (in truth, Google was the source for > > > > everything in my previous post). Best I can come up with might be related > > > > to > > > > > > > > https://linux.die.net/man/8/ldconfig > > > > > > > > Does > > > > ldconfig -p > > > > list the file? If not... is /usr/local/lib somewhere in /etc/ld.so.conf (or > > > > any subfiles referenced)? The Debian on Windows seems to have it > > > > included... > > > > > > > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf > > > > include /etc/ld.so.conf.d/*.conf > > > > > > > > wulfraed at ElusiveUnicorn:~$ ls /etc/ld.so.conf.d/ > > > > libc.conf x86_64-linux-gnu.conf > > > > wulfraed at ElusiveUnicorn:~$ cat /etc/ld.so.conf.d/*.conf > > > > # libc default configuration > > > > /usr/local/lib > > > > # Multiarch support > > > > /lib/x86_64-linux-gnu > > > > /usr/lib/x86_64-linux-gnu > > > > wulfraed at ElusiveUnicorn:~$ > > > > > > > > Even with it (the directory) there, you may need to rebuild cache by > > > > running ldconfig > > > > > > > > > > > > -- > > > > Wulfraed Dennis Lee Bieber AF6VN > > > > wlfraed at ix.netcom.com http://wlfraed.microdiversity.freeddns.org/ > > > > > > > > _______________________________________________ > > > > Flask mailing list > > > > Flask at python.org > > > > https://mail.python.org/mailman/listinfo/flask > > > _______________________________________________ > > > Flask mailing list > > > Flask at python.org > > > https://mail.python.org/mailman/listinfo/flask From larry.martell at gmail.com Tue Aug 13 07:36:08 2019 From: larry.martell at gmail.com (Larry Martell) Date: Tue, 13 Aug 2019 07:36:08 -0400 Subject: [Flask] Connecting to 2 servers In-Reply-To: References: <0ov2letm9b99fdauvhgl3f4q5cduddh2k1@4ax.com> <0ov2letm9b99fdauvhgl3f4q5cduddh2k1-e09XROE/p8c@public.gmane.org> Message-ID: On Mon, Aug 12, 2019 at 11:28 PM Dennis Lee Bieber wrote: > > On Mon, 12 Aug 2019 15:13:15 -0400, Larry Martell > declaimed the > following: > > >If I run ldconfig -v I can see it search in > > > >/lib: > >/lib64: > >/usr/lib: > >/usr/lib64: > > > >I tried symlinking /usr/local/lib/libmsodbcsql.17.dylib to /usr/lib > >but it still did not pick it up. > > What if you provide /usr/local/lib as an argument to ldconfig > ? > I was finally able to get past this issue by doing this: sudo yum remove unixODBC curl http://mirror.centos.org/centos/7/os/x86_64/Packages/unixODBC-2.3.1-11.el7.x86_64.rpm >/tmp/unixODBC231.rpm sudo rpm -i /tmp/unixODBC231.rpm sudo ACCEPT_EULA=Y yum install msodbcsql17 However now my login to the DB is timing out. From linux4ms at gmail.com Wed Aug 14 08:51:55 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 14 Aug 2019 07:51:55 -0500 Subject: [Flask] Explanation, Please ... Message-ID: From: https://jinja.palletsprojects.com/en/master/templates/#whitespace-control Comes the words of wisdom: The following example implements a sitemap with recursive loops:
    {%- for *item* in *sitemap* recursive %}
  • {{ item.title }} {%- if item.children -%} {%- endif %}
  • {%- endfor %}
What data type is sitemap in the for loop? and what is the 'item' data type and what does it contain ? (Possible sample ?) Thanks ... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Wed Aug 14 13:41:35 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Wed, 14 Aug 2019 12:41:35 -0500 Subject: [Flask] Which to use for DB ? Message-ID: Ok from: https://flask.palletsprojects.com/en/1.1.x/patterns/sqlalchemy/ I understand the SQLAlchemy part, unsure of the flask_sqlalchemy Which should I use? Standard SQLAlchemy or the Flask_Sqlaclchemy ? I'm having trouble with predefined and in-use database , why I'm asking ... Thanks .... *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From yuxuan.dong at outlook.com Wed Aug 14 14:30:10 2019 From: yuxuan.dong at outlook.com (Yuxuan Dong) Date: Wed, 14 Aug 2019 18:30:10 +0000 Subject: [Flask] Which to use for DB ? In-Reply-To: References: Message-ID: I think there is not a standard answer for all projects. Flask-SQLAlchemy is using scoped_seasion, which is very convient but not very flexible. You can also use context manager to build your own session manager. I took a note about these two usage, may be helpful: http://yxdong.me/posts/sqlalchemy-session-usage-patterns-in-web-applications.html ?? Outlook for iOS ________________________________ ???: Flask ?? Ben Duncan ????: Thursday, August 15, 2019 1:41:35 AM ???: Flask User Groups ??: [Flask] Which to use for DB ? Ok from: https://flask.palletsprojects.com/en/1.1.x/patterns/sqlalchemy/ I understand the SQLAlchemy part, unsure of the flask_sqlalchemy Which should I use? Standard SQLAlchemy or the Flask_Sqlaclchemy ? I'm having trouble with predefined and in-use database , why I'm asking ... Thanks .... Ben Duncan DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From linux4ms at gmail.com Mon Aug 19 09:25:29 2019 From: linux4ms at gmail.com (Ben Duncan) Date: Mon, 19 Aug 2019 08:25:29 -0500 Subject: [Flask] flask-SqlAlchemy question Message-ID: Ok, i'm trying to use the flask-sqlalchmey I am trying to load a single table without having to do a reflect: Code: pgdb = SQLAlchemy(app) # Get our Company Stuff pgdb.Model.metadata.reflect(pgdb.engine) class comp_table(pgdb.Model): __table__ = pgdb.Model.metadata.tables['company'] # I'd rather do something like: comp_table = pgdb.Model.metadata.tables['company'] rather the load everything thru reflect Is there a way to do this ? Thanks *Ben Duncan* DBA / Chief Software Architect Mississippi State Supreme Court Electronic Filing Division -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.martell at gmail.com Wed Aug 21 13:49:34 2019 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 21 Aug 2019 13:49:34 -0400 Subject: [Flask] Getting 404 on one endpoint on one system Message-ID: I have a flask app deployed on 2 systems. On one system all endpoints work. On the other 1 endpoint gives a 404 (all the others work). I have verified that the code is identical on both systems. Anyone have any thoughts on what could be going on or how I can debug this? From yuxuan.dong at outlook.com Wed Aug 21 13:58:53 2019 From: yuxuan.dong at outlook.com (Yu-Xuan Dong) Date: Wed, 21 Aug 2019 17:58:53 +0000 Subject: [Flask] Getting 404 on one endpoint on one system In-Reply-To: References: Message-ID: It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? YX. D. ________________________________ ???: Flask ?? Larry Martell ????: Thursday, August 22, 2019 1:49:34 AM ???: flask at python.org ??: [Flask] Getting 404 on one endpoint on one system I have a flask app deployed on 2 systems. On one system all endpoints work. On the other 1 endpoint gives a 404 (all the others work). I have verified that the code is identical on both systems. Anyone have any thoughts on what could be going on or how I can debug this? _______________________________________________ Flask mailing list Flask at python.org https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From larry.martell at gmail.com Wed Aug 21 14:03:11 2019 From: larry.martell at gmail.com (Larry Martell) Date: Wed, 21 Aug 2019 14:03:11 -0400 Subject: [Flask] Getting 404 on one endpoint on one system In-Reply-To: References: Message-ID: On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: > > It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? mod_wsgi-express but I get the same results running from the command line. > > YX. D. > ________________________________ > ???: Flask ?? Larry Martell > ????: Thursday, August 22, 2019 1:49:34 AM > ???: flask at python.org > ??: [Flask] Getting 404 on one endpoint on one system > > I have a flask app deployed on 2 systems. On one system all endpoints > work. On the other 1 endpoint gives a 404 (all the others work). I > have verified that the code is identical on both systems. Anyone have > any thoughts on what could be going on or how I can debug this? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask From yuxuan.dong at outlook.com Thu Aug 22 00:17:53 2019 From: yuxuan.dong at outlook.com (Yu-Xuan Dong) Date: Thu, 22 Aug 2019 04:17:53 +0000 Subject: [Flask] Getting 404 on one endpoint on one system In-Reply-To: References: , Message-ID: You mean it has the same issue even you use the dev server of Flask? 1. Do Python/Flask on two system have the same version? 2. Could you provide your definition code of the endpoint? YX. D. ________________________________ ???: Larry Martell ????: Thursday, August 22, 2019 2:03:11 AM ???: Yu-Xuan Dong ??: flask at python.org ??: Re: [Flask] Getting 404 on one endpoint on one system On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: > > It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? mod_wsgi-express but I get the same results running from the command line. > > YX. D. > ________________________________ > ???: Flask ?? Larry Martell > ????: Thursday, August 22, 2019 1:49:34 AM > ???: flask at python.org > ??: [Flask] Getting 404 on one endpoint on one system > > I have a flask app deployed on 2 systems. On one system all endpoints > work. On the other 1 endpoint gives a 404 (all the others work). I > have verified that the code is identical on both systems. Anyone have > any thoughts on what could be going on or how I can debug this? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask -------------- next part -------------- An HTML attachment was scrubbed... URL: From adamenglander at yahoo.com Thu Aug 22 09:24:55 2019 From: adamenglander at yahoo.com (Adam Englander) Date: Thu, 22 Aug 2019 06:24:55 -0700 Subject: [Flask] Getting 404 on one endpoint on one system Message-ID: <028CDB26-9835-4732-806C-8DB4EE93CABB@yahoo.com> Do you have code that looks up an entity and returns a 404 if not found? That tends to be how I get that difference in two environments. Adam Englander > On Aug 21, 2019, at 9:17 PM, flask-request at python.org wrote: > > Send Flask mailing list submissions to > flask at python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/flask > or, via email, send a message with subject or body 'help' to > flask-request at python.org > > You can reach the person managing the list at > flask-owner at python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Flask digest..." > > > Today's Topics: > > 1. Getting 404 on one endpoint on one system (Larry Martell) > 2. Re: Getting 404 on one endpoint on one system (Yu-Xuan Dong) > 3. Re: Getting 404 on one endpoint on one system (Larry Martell) > 4. Re: Getting 404 on one endpoint on one system (Yu-Xuan Dong) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 21 Aug 2019 13:49:34 -0400 > From: Larry Martell > To: flask at python.org > Subject: [Flask] Getting 404 on one endpoint on one system > Message-ID: > > Content-Type: text/plain; charset="UTF-8" > > I have a flask app deployed on 2 systems. On one system all endpoints > work. On the other 1 endpoint gives a 404 (all the others work). I > have verified that the code is identical on both systems. Anyone have > any thoughts on what could be going on or how I can debug this? > > > ------------------------------ > > Message: 2 > Date: Wed, 21 Aug 2019 17:58:53 +0000 > From: Yu-Xuan Dong > To: Larry Martell , "flask at python.org" > > Subject: Re: [Flask] Getting 404 on one endpoint on one system > Message-ID: > > > Content-Type: text/plain; charset="gb2312" > > It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > YX. D. > ________________________________ > ???: Flask ?? Larry Martell > ????: Thursday, August 22, 2019 1:49:34 AM > ???: flask at python.org > ??: [Flask] Getting 404 on one endpoint on one system > > I have a flask app deployed on 2 systems. On one system all endpoints > work. On the other 1 endpoint gives a 404 (all the others work). I > have verified that the code is identical on both systems. Anyone have > any thoughts on what could be going on or how I can debug this? > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 3 > Date: Wed, 21 Aug 2019 14:03:11 -0400 > From: Larry Martell > To: Yu-Xuan Dong > Cc: "flask at python.org" > Subject: Re: [Flask] Getting 404 on one endpoint on one system > Message-ID: > > Content-Type: text/plain; charset="UTF-8" > >> On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: >> >> It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > mod_wsgi-express but I get the same results running from the command line. > >> >> YX. D. >> ________________________________ >> ???: Flask ?? Larry Martell >> ????: Thursday, August 22, 2019 1:49:34 AM >> ???: flask at python.org >> ??: [Flask] Getting 404 on one endpoint on one system >> >> I have a flask app deployed on 2 systems. On one system all endpoints >> work. On the other 1 endpoint gives a 404 (all the others work). I >> have verified that the code is identical on both systems. Anyone have >> any thoughts on what could be going on or how I can debug this? >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > > > ------------------------------ > > Message: 4 > Date: Thu, 22 Aug 2019 04:17:53 +0000 > From: Yu-Xuan Dong > To: Larry Martell > Cc: "flask at python.org" > Subject: Re: [Flask] Getting 404 on one endpoint on one system > Message-ID: > > > Content-Type: text/plain; charset="gb2312" > > You mean it has the same issue even you use the dev server of Flask? > > 1. Do Python/Flask on two system have the same version? > > 2. Could you provide your definition code of the endpoint? > > YX. D. > ________________________________ > ???: Larry Martell > ????: Thursday, August 22, 2019 2:03:11 AM > ???: Yu-Xuan Dong > ??: flask at python.org > ??: Re: [Flask] Getting 404 on one endpoint on one system > >> On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: >> >> It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > mod_wsgi-express but I get the same results running from the command line. > >> >> YX. D. >> ________________________________ >> ???: Flask ?? Larry Martell >> ????: Thursday, August 22, 2019 1:49:34 AM >> ???: flask at python.org >> ??: [Flask] Getting 404 on one endpoint on one system >> >> I have a flask app deployed on 2 systems. On one system all endpoints >> work. On the other 1 endpoint gives a 404 (all the others work). I >> have verified that the code is identical on both systems. Anyone have >> any thoughts on what could be going on or how I can debug this? >> _______________________________________________ >> Flask mailing list >> Flask at python.org >> https://mail.python.org/mailman/listinfo/flask > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Flask mailing list > Flask at python.org > https://mail.python.org/mailman/listinfo/flask > > > ------------------------------ > > End of Flask Digest, Vol 50, Issue 16 > ************************************* From larry.martell at gmail.com Thu Aug 22 11:11:32 2019 From: larry.martell at gmail.com (Larry Martell) Date: Thu, 22 Aug 2019 11:11:32 -0400 Subject: [Flask] Getting 404 on one endpoint on one system In-Reply-To: <028CDB26-9835-4732-806C-8DB4EE93CABB@yahoo.com> References: <028CDB26-9835-4732-806C-8DB4EE93CABB@yahoo.com> Message-ID: On Thu, Aug 22, 2019 at 9:25 AM Adam Englander via Flask wrote: > > Do you have code that looks up an entity and returns a 404 if not found? That tends to be how I get that difference in two environments. Indeed that is exactly what was happening. I did not write the code so I did not realize that was the case. I discovered that late yesterday. > > Date: Wed, 21 Aug 2019 13:49:34 -0400 > > From: Larry Martell > > To: flask at python.org > > Subject: [Flask] Getting 404 on one endpoint on one system > > Message-ID: > > > > Content-Type: text/plain; charset="UTF-8" > > > > I have a flask app deployed on 2 systems. On one system all endpoints > > work. On the other 1 endpoint gives a 404 (all the others work). I > > have verified that the code is identical on both systems. Anyone have > > any thoughts on what could be going on or how I can debug this? > > > > > > ------------------------------ > > > > Message: 2 > > Date: Wed, 21 Aug 2019 17:58:53 +0000 > > From: Yu-Xuan Dong > > To: Larry Martell , "flask at python.org" > > > > Subject: Re: [Flask] Getting 404 on one endpoint on one system > > Message-ID: > > > > > > Content-Type: text/plain; charset="gb2312" > > > > It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > > > YX. D. > > ________________________________ > > ???: Flask ?? Larry Martell > > ????: Thursday, August 22, 2019 1:49:34 AM > > ???: flask at python.org > > ??: [Flask] Getting 404 on one endpoint on one system > > > > I have a flask app deployed on 2 systems. On one system all endpoints > > work. On the other 1 endpoint gives a 404 (all the others work). I > > have verified that the code is identical on both systems. Anyone have > > any thoughts on what could be going on or how I can debug this? > > _______________________________________________ > > Flask mailing list > > Flask at python.org > > https://mail.python.org/mailman/listinfo/flask > > -------------- next part -------------- > > An HTML attachment was scrubbed... > > URL: > > > > ------------------------------ > > > > Message: 3 > > Date: Wed, 21 Aug 2019 14:03:11 -0400 > > From: Larry Martell > > To: Yu-Xuan Dong > > Cc: "flask at python.org" > > Subject: Re: [Flask] Getting 404 on one endpoint on one system > > Message-ID: > > > > Content-Type: text/plain; charset="UTF-8" > > > >> On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: > >> > >> It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > > > mod_wsgi-express but I get the same results running from the command line. > > > >> > >> YX. D. > >> ________________________________ > >> ???: Flask ?? Larry Martell > >> ????: Thursday, August 22, 2019 1:49:34 AM > >> ???: flask at python.org > >> ??: [Flask] Getting 404 on one endpoint on one system > >> > >> I have a flask app deployed on 2 systems. On one system all endpoints > >> work. On the other 1 endpoint gives a 404 (all the others work). I > >> have verified that the code is identical on both systems. Anyone have > >> any thoughts on what could be going on or how I can debug this? > >> _______________________________________________ > >> Flask mailing list > >> Flask at python.org > >> https://mail.python.org/mailman/listinfo/flask > > > > > > ------------------------------ > > > > Message: 4 > > Date: Thu, 22 Aug 2019 04:17:53 +0000 > > From: Yu-Xuan Dong > > To: Larry Martell > > Cc: "flask at python.org" > > Subject: Re: [Flask] Getting 404 on one endpoint on one system > > Message-ID: > > > > > > Content-Type: text/plain; charset="gb2312" > > > > You mean it has the same issue even you use the dev server of Flask? > > > > 1. Do Python/Flask on two system have the same version? > > > > 2. Could you provide your definition code of the endpoint? > > > > YX. D. > > ________________________________ > > ???: Larry Martell > > ????: Thursday, August 22, 2019 2:03:11 AM > > ???: Yu-Xuan Dong > > ??: flask at python.org > > ??: Re: [Flask] Getting 404 on one endpoint on one system > > > >> On Wed, Aug 21, 2019 at 1:58 PM Yu-Xuan Dong wrote: > >> > >> It may be caused by your HTTP server config. What HTTP server are you using and how do you canfigure it? > > > > mod_wsgi-express but I get the same results running from the command line.
Records
Account NameAccount Number {{ sort_form.sortby_date() }} {{ sort_form.sortby_description () }} > Amount {{ sort_form.sortby_category() }} {{ sort_form.sortby_subcategory () }} >