Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection options in the open function #122

Closed
szkiba opened this issue Feb 21, 2025 · 0 comments · Fixed by #123
Closed

Connection options in the open function #122

szkiba opened this issue Feb 21, 2025 · 0 comments · Fixed by #123
Assignees
Labels
enhancement New feature or request

Comments

@szkiba
Copy link
Contributor

szkiba commented Feb 21, 2025

An optional options parameter should be used to specify database connection-related options.

sql.open(driver, "roster_db",opts)

Properties:

  • conn_max_idle_time: Sets the maximum amount of time a connection may be idle. If 0, connections are not closed due to a connection's idle time. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". Example:
    const db = sql.open(driver, "roster_db", { conn_max_idle_time: "1h10m10s" });
  • conn_max_lifetime: Sets the maximum amount of time a connection may be reused. If 0, connections are not closed due to a connection's age. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". Example:
    const db = sql.open(driver, "roster_db", { conn_max_lifetime: "10h" });
  • max_idle_conns: Sets the maximum number of connections in the idle connection pool. If 0, no idle connections are retained. The default is currently 2. Example:
    const db = sql.open(driver, "roster_db", { max_idle_conns: 3 });
  • max_open_conns: Sets the maximum number of open connections to the database. If 0, then there is no limit on the number of open connections. The default is 0 (unlimited). Example:
    const db = sql.open(driver, "roster_db", { max_open_conns: 100 });
@szkiba szkiba added the enhancement New feature or request label Feb 21, 2025
@szkiba szkiba self-assigned this Feb 21, 2025
@szkiba szkiba linked a pull request Feb 21, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant