Git Product home page Git Product logo

Comments (4)

oiwn avatar oiwn commented on May 21, 2024

I got same thing using Flask with SQLAlchemy before.

http://stackoverflow.com/questions/16341911/sqlalchemy-error-mysql-server-has-gone-away
http://stackoverflow.com/questions/6471549/avoiding-mysql-server-has-gone-away-on-infrequently-used-python-flask-server

from grab.

asakasinsky avatar asakasinsky commented on May 21, 2024

Hi, @lorien
There are my db.py, SQLAlchemy template for all my projects. Parsers, Flask sites etc.
«mysql has gone away» is solved.

I drop this file into some project, example:
..
./models/
./app.py
./db.py

and init db in app:

from db import db_session, init_db
SQLALCHEMY_DATABASE_URI = "mysql+mysqldb://%s:%s@%s/%s?charset=utf8" % (db_user, db_pass, db_host, db_name)
init_db(SQLALCHEMY_DATABASE_URI)
...
...
db_session.add(Model)
db_session.commit()

And Model:

from sqlalchemy import (
    Column,
    Integer,
)
from db import Base

class User(Base):
    """User Model"""
    __tablename__ = 'users'
    id = Column(Integer, primary_key=True)

from grab.

asakasinsky avatar asakasinsky commented on May 21, 2024

«Patch» action log:
2014-10-13 17:47:30,027 INFO sqlalchemy.pool.QueuePool Connection <_mysql.connection open to '127.0.0.1' at 7ffcb48eca20> exceeded timeout; recycling
2014-10-14 21:02:31,507 INFO sqlalchemy.pool.QueuePool Connection <_mysql.connection open to '127.0.0.1' at 7ffcb4002220> exceeded timeout; recycling

from grab.

lorien avatar lorien commented on May 21, 2024

Пожалуй, закрою этот тикет, так как я его сам открывал, а фунциональность эта мне уже сто лет как не нужна.

from grab.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.