On 03/03/2017 06:31 PM, Евгений Рымарев wrote:
call_special_firebird_method
Not understand. What method? You mean fdb method?

yes, whatever workaround fdb gives you for this issue.


I found method _Connection__set_default_tpb and use it.
|
app =Flask(__name__)
app.config.from_pyfile(filename='settings.py',silent=True)
db =SQLAlchemy(app=app)
engine =create_engine(settings.SQLALCHEMY_DATABASE_URI)

@event.listens_for(engine,'connect')
defreceive_connect(dbapi_connection,connection_record):

dbapi_connection._Connection__set_default_tpb(ISOLATION_LEVEL_READ_COMMITED_LEGACY)
|
This function is performed, but the same result - error in logs about
"lock".

I know nothing about this issue on Firebird you'd need to ask on their mailing list for how to deal with this situation.






пятница, 3 марта 2017 г., 20:08:45 UTC+3 пользователь Евгений Рымарев
написал:

    Hello everyone!
    I have Flask app with using flask_sqlalchemy:

    |
    fromflask importFlask
    fromflask_sqlalchemy importSQLAlchemy
    app =Flask(__name__)
    app.config.from_pyfile(filename='settings.py',silent=True)
    db =SQLAlchemy(app=app)
    |

    I want connect to same database from daemon. In daemon i just import
    db and use db.engine.execute for SQLAlchemy queries.
    But when daemon starts main app can't connect to database.
    In log i see that:
    |
    fdb.fbcore.DatabaseError:('Error while connecting to database:\n-
    SQLCODE: -902\n- I/O error during "lock" operation for file
    "main.fdb"\n- Database already opened with engine instance,
    incompatible with current',-902,335544344)
    |

    I trying use isolation level:
    |
    fromfdb.fbcore importISOLATION_LEVEL_READ_COMMITED_LEGACY
    classTPBAlchemy(SQLAlchemy):
        defapply_driver_hacks(self,app_,info,options):
            if'isolation_level'notinoptions:

    options['isolation_level']=ISOLATION_LEVEL_READ_COMMITED_LEGACY

    returnsuper(TPBAlchemy,self).apply_driver_hacks(app_,info,options)
    |

    And replace this:
    |
    db =SQLAlchemy()
    |

    To:
    |
    db =TPBAlchemy()
    |

    But this only make another error:
    |
    TypeError:Invalidargument(s)'isolation_level'sent to
    create_engine(),usingconfiguration
    FBDialect_fdb/QueuePool/Engine. Pleasecheck that the keyword
    arguments are appropriate forthiscombination of components.
    |

    I would appreciate the full example to address my issue.
    Thanks!

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

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and
Verifiable Example. See http://stackoverflow.com/help/mcve for a full
description.
---
You received this message because you are subscribed to the Google
Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to sqlalchemy+unsubscr...@googlegroups.com
<mailto:sqlalchemy+unsubscr...@googlegroups.com>.
To post to this group, send email to sqlalchemy@googlegroups.com
<mailto:sqlalchemy@googlegroups.com>.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

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

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to