Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 31 2019 16:42
    fantix commented #428
  • Jan 31 2019 14:11
    wwwjfy labeled #432
  • Jan 31 2019 14:11
    wwwjfy commented #432
  • Jan 31 2019 14:10

    wwwjfy on pyup-update-pytest-4.1.0-to-4.2.0

    (compare)

  • Jan 31 2019 14:10

    wwwjfy on master

    Update pytest from 4.1.0 to 4.2… (compare)

  • Jan 31 2019 14:10
    wwwjfy closed #431
  • Jan 31 2019 13:05
    diegoyosiura opened #432
  • Jan 31 2019 07:08
    aliyarly starred fantix/gino
  • Jan 31 2019 03:48
    coveralls commented #431
  • Jan 31 2019 03:41
    pyup-bot opened #431
  • Jan 31 2019 03:41

    fantix on pyup-update-pytest-4.1.0-to-4.2.0

    Update pytest from 4.1.0 to 4.2… (compare)

  • Jan 31 2019 03:41

    fantix on pyup-update-pytest-4.1.0-to-4.2.0

    (compare)

  • Jan 31 2019 01:55
  • Jan 30 2019 13:55

    wwwjfy on pyup-update-quart-0.6.10-to-0.7.0

    (compare)

  • Jan 30 2019 13:06

    wwwjfy on pyup-update-flake8-3.5.0-to-3.7.1

    (compare)

  • Jan 30 2019 13:06

    wwwjfy on master

    Update flake8 from 3.5.0 to 3.7… use latest flake8 in tests, ref… Merge pull request #430 from fa… (compare)

  • Jan 30 2019 13:06
    wwwjfy closed #430
  • Jan 30 2019 13:03
    coveralls commented #430
  • Jan 30 2019 12:58
    wwwjfy synchronize #430
  • Jan 30 2019 12:58

    wwwjfy on pyup-update-flake8-3.5.0-to-3.7.1

    use latest flake8 in tests, ref… (compare)

Wilson Beirigo Duarte
@wbeirigo_gitlab
Hi all. How to use pre-existing database with Gino?
6 replies
nichotin95
@nichotin95
Hi chat. I'm stuck with a usecase of mine corresponding the loaders.
So I've written down my own "ON" clause as the tables in consideration don't have and foreign-key relation. But I'm not sure how to load distinct children in the Parent using the "distinct" keyword.
loader = Parent.load(add_child=Childern.on(child_and_clause))
result = ( await loader.query.where(Parent.id == parent_id) .where(Parent.knowledge_end_date == None) .gino.first() )
This is loading the same Child instance in the parent again-and-again and I'm not sure how to use the distinct keyword here.
child_and_clause is working fine as the output is correct, justa that it is being added multiple times
nichotin95
@nichotin95
Nvm. Got this to work by creating dunder eq method in the model class
rlundy82
@rlundy82
I'm using Gino inside my Celery apps using this line
async with db.with_bind(settings.SQL_DRIVER, echo=False) as engine:
For some reason I can't get echo to turn off.
I am using the sanic ext:
from gino.ext.sanic import Gino
db = Gino()
Lu
@ZinkLu

I'm using Gino inside my Celery apps using this line
async with db.with_bind(settings.SQL_DRIVER, echo=False) as engine:
For some reason I can't get echo to turn off.

Hi! @rlundy82. I came across the same issue while using uvicorn with Sanic+Gino. the easiest way to disable db echo is to set a higher logging level to gino_logger:

import logging
logging.getLogger("gino").setLevel(logging.WARNING)
nichotin95
@nichotin95
@fantix @wwwjfy Do we have sqlalchemy type events in place? (like after_create, after_update, etc.) Or is there any decent way to achieve this?
Solution provided here looks a bit hacky and I'm not very convinced if I should implement something like this (If any of you approves, I can go and implement a similar setup). Thanks :)
Fantix King
@fantix
these events are on SQLAlchemy ORM mapped objects right?
nichotin95
@nichotin95
Correct
Fantix King
@fantix
Would something like a helper function work? For example, define a create_user function to be 1) user = User.create(), and 2) user.xxx = yyy as the after_create hook
then call create_user() instead of User.create()
or alternatively override User.create method
Just my first reaction to this question, would require more use cases though
nichotin95
@nichotin95
Ohh okay, I get it. This certainly can be implemented. But any core event like creation of the table, how should one handle that?
Fantix King
@fantix
hmm "creation of the table" assumes the use of something like User.__table__.create() or db.gino.create_all()
such hooks could be added
but the create() and create_all() functions are a bit less elegant - they're copied from SQLAlchemy and manipulated to be async, so I'm overall not a big fan
nichotin95
@nichotin95
Ok. So my use case was to add a trigger right after a table is created, if the table is not created, don't do anything. I can certainly use such hooks, or write an intelligent query which checks for the presence of the trigger. Thanks for such spontaneous inputs :)
Fantix King
@fantix
oh sure
nichotin95
@nichotin95
Yeah, but currently we are not planning to add a tool like alembic in the setup as it had some limitations when I lasted tested it wit docker and kubernetes. Might add that sometime later though, after a proper understanding
Fantix King
@fantix
makes sense
the create_async or GinoSchemaVisitor.create might be the places to override
nichotin95
@nichotin95
Yeah, feels like I'm looking at the right place finally. Thanks
Fantix King
@fantix
:+1: good luck!
Dima Veselov
@dveselov
Hi guys, does anybody knows how to wrap all pytest (pytest-asyncio) + sanic/aiohttp test cases in transactions? Seems like there is multiple different event loops, and asyncpg can't work in this conditions (similar issue like I have: python-gino/gino#713)
1 reply
As alternative solution I'm already do TRUNCATE at end of each test case, but it is too slow, nearly 1 second for each test case. Transactions can improve mine test run time significally, I think.
As final solution I want have something like django test cases, where transaction starts at setup_method and rollbacks at teardown_method.
Thanks in advance.
rlundy82
@rlundy82
@ZinkLu Thanks, this worked!
ivan-pozniak
@ivan-pozniak_gitlab

Hi. May be anybody knows why sqlalchemy query execute faster then Gino query. I have this type pf code with Gino

async with db.with_bind(connecting_str) as engine:
            instructions = await Instruction.query.where(Instruction.id==int(instruction_id)
                                    ).where(Instruction.trigger_id==int(instruction['trigger_id'])).gino.first()
            await instructions.update(blocks=instruction['blocks']).apply()

. And my SQLAlchemy code:

with AlchemySession() as db:
            db.session.query(Trigger).filter(Trigger.id == trigger_id).update({'instructions_id': request['instructions_id']})
            db.session.commit()
Aleksandr
@Aleksandr_fuze_gitlab
@ivan-pozniak_gitlab
You use 2 requests with gino (getting object then updating) and one with alchemy, only updating. Furthermore, you use different conditions on queries...
ivan-pozniak
@ivan-pozniak_gitlab
@Aleksandr_fuze_gitlab How can I update my parent table with child data like in sqlalchemy?
ivan-pozniak
@ivan-pozniak_gitlab

How can we use update query in sqlalchemy

db.session.query(Trigger).filter(Trigger.id == trigger_id).update({'instructions_id': request['instructions_id']})

style for one-to-many relations?
Shall we do it without getting foreign key and then find child table with this key and after that update this row?

2 replies
ivan-pozniak
@ivan-pozniak_gitlab
Hi! If i have gino query should i always use ayncio.sleep() in the end of the query?
1 reply
Filip Mićić
@MicicFilip
@fantix hey man, first of all good job on creating Gino! I was wondering if it is possible to filter a table using someting like filter_by from sqlalchemy where you could just filter arguments without having to pass table columns? Keep up the good work, thanks in advance!
2 replies
Cobalt
@Chaostheorie
@fantix Hey, is there any maintainer for gino-quart at them moment? I would love to take care of, because I use it for multiple projects at the moment and plan to include it in a guide for gino with quart.
Fantix King
@fantix
@Chaostheorie Oh sure - I truly appreciate that! There's currently no maintainer for gino-quart yet.
Cobalt
@Chaostheorie
@fantix I will probably create a pull request with bumps to the newer versions (gino and quart) in the next days. Is there a chance of it being reviewed? If not, I would otherwise love to be a maintainer for this repo.
Is there some person to message about this
?
Fantix King
@fantix
What's your github username pls?
Cobalt
@Chaostheorie
Cobalt <@Chaostheorie>
I'm writing a guide that takes advantage of gino and quart and would like to use this package in this guide -> migrating the package with changes I already have for my projects working
Fantix King
@fantix
Invitation sent ❤️
Cobalt
@Chaostheorie
Thanks a lot
The changes will be up and tested in a few days
Fantix King
@fantix
sounds great!
Cobalt
@Chaostheorie
@fantix Would you be able to release gino-quart/v0.0.1b0 to pypi as prerelease? Tests are passing etc