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 #123

Merged
merged 1 commit into from
Feb 21, 2025

Conversation

szkiba
Copy link
Contributor

@szkiba szkiba commented Feb 21, 2025

Connection options in the open function: An optional options parameter can be used in open() 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 });

Also fixex #113

@szkiba szkiba requested a review from a team as a code owner February 21, 2025 16:37
@szkiba szkiba requested review from pablochacin and removed request for a team February 21, 2025 16:37
@szkiba szkiba linked an issue Feb 21, 2025 that may be closed by this pull request
@szkiba szkiba removed the request for review from pablochacin February 21, 2025 16:38
@szkiba szkiba merged commit d47a5cd into main Feb 21, 2025
25 checks passed
@szkiba szkiba deleted the 122-connection-options-in-the-open-function branch February 21, 2025 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connection options in the open function
1 participant