Git Product home page Git Product logo

Comments (6)

dlo avatar dlo commented on August 15, 2024

Would you want the connection to die past a certain limit or do you want to extend the limit?

from django-pyodbc.

tzenderman avatar tzenderman commented on August 15, 2024

For the connection to die past a certain limit so the user gets a quicker response.

from django-pyodbc.

dlo avatar dlo commented on August 15, 2024

I think this may be something you need to do on the database server itself (e.g., through SQL Server). @michiya what do you think?

from django-pyodbc.

michiya avatar michiya commented on August 15, 2024

Hi guys,

If you are using FreeTDS, you might be able to specify timeout values with timeout or connect timeout settings in freetds.conf. For more details, see:
http://freetds.schemamania.org/userguide/freetdsconf.htm

But if you are using MS ODBC drivers, probably there's no way to specify timeout values at this time because they don't support Connect Timeout keyword in the connection string.

And now, pyodbc provides the following way to specify timeout values:

  • timeout kwarg in podbc.connect()
    this represents SQL_ATTR_LOGIN_TIMEOUT in the ODBC spec.
  • timeout attribute of Connection object
    this represents SQL_ATTR_CONNECTION_TIMEOUT and SQL_ATTR_QUERY_TIMEOUT in the ODBC spec.

and you can specify timeout values with pyodbc like this:

# connect to the database in 3 seconds
conn = pyodbc.connect(connstr, timeout=3)
# set connection/query timeout to 5 seconds
conn.timeout = 5

So it might be a good idea to slightly modify the backend as above to accept these timeout-related options in the database settings.

from django-pyodbc.

tzenderman avatar tzenderman commented on August 15, 2024

Thanks for the info guys!

On Thu, Aug 1, 2013 at 3:21 AM, Michiya Takahashi
[email protected]:

Hi guys,

If you are using FreeTDS, you might be able to specify timeout values with
timeout or connect timeout settings in freetds.conf. For more details,
see:
http://freetds.schemamania.org/userguide/freetdsconf.htm

But if you are using MS ODBC drivers, probably there's no way to specify
timeout values at this time because they don't support Connect Timeoutkeyword in the connection string.

And now, pyodbc provides the following way to specify timeout values:

timeout kwarg in podbc.connect()
this represents SQL_ATTR_LOGIN_TIMEOUT in the ODBC spec.

timeout attribute of Connection object
this represents SQL_ATTR_CONNECTION_TIMEOUT and SQL_ATTR_QUERY_TIMEOUT
in the ODBC spec.

and you can specify timeout values with pyodbc like this:

connect to the database in 3 secondsconn = pyodbc.connect(connstr, timeout=3)# set connection/query timeout to 5 secondsconn.timeout = 5

So it might be a good idea to slightly modify the backend as above to
accept these timeout-related options in the database settings.


Reply to this email directly or view it on GitHubhttps://github.com//issues/18#issuecomment-21917075
.

from django-pyodbc.

michiya avatar michiya commented on August 15, 2024

@dlo I will add support for these timeout-related database options to the backend if you agree with that. What do you think of that?

from django-pyodbc.

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.