CARVIEW |
Select Language
HTTP/2 200
date: Sat, 19 Jul 2025 07:44:54 GMT
content-type: text/html; charset=utf-8
vary: X-PJAX, X-PJAX-Container, Turbo-Visit, Turbo-Frame, X-Requested-With,Accept-Encoding, Accept, X-Requested-With
etag: W/"50189b4dcb26985b2145719ea1e1b89f"
cache-control: max-age=0, private, must-revalidate
strict-transport-security: max-age=31536000; includeSubdomains; preload
x-frame-options: deny
x-content-type-options: nosniff
x-xss-protection: 0
referrer-policy: no-referrer-when-downgrade
content-security-policy: default-src 'none'; base-uri 'self'; child-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/; connect-src 'self' uploads.github.com www.githubstatus.com collector.github.com raw.githubusercontent.com api.github.com github-cloud.s3.amazonaws.com github-production-repository-file-5c1aeb.s3.amazonaws.com github-production-upload-manifest-file-7fdce7.s3.amazonaws.com github-production-user-asset-6210df.s3.amazonaws.com *.rel.tunnels.api.visualstudio.com wss://*.rel.tunnels.api.visualstudio.com objects-origin.githubusercontent.com copilot-proxy.githubusercontent.com proxy.individual.githubcopilot.com proxy.business.githubcopilot.com proxy.enterprise.githubcopilot.com *.actions.githubusercontent.com wss://*.actions.githubusercontent.com productionresultssa0.blob.core.windows.net/ productionresultssa1.blob.core.windows.net/ productionresultssa2.blob.core.windows.net/ productionresultssa3.blob.core.windows.net/ productionresultssa4.blob.core.windows.net/ productionresultssa5.blob.core.windows.net/ productionresultssa6.blob.core.windows.net/ productionresultssa7.blob.core.windows.net/ productionresultssa8.blob.core.windows.net/ productionresultssa9.blob.core.windows.net/ productionresultssa10.blob.core.windows.net/ productionresultssa11.blob.core.windows.net/ productionresultssa12.blob.core.windows.net/ productionresultssa13.blob.core.windows.net/ productionresultssa14.blob.core.windows.net/ productionresultssa15.blob.core.windows.net/ productionresultssa16.blob.core.windows.net/ productionresultssa17.blob.core.windows.net/ productionresultssa18.blob.core.windows.net/ productionresultssa19.blob.core.windows.net/ github-production-repository-image-32fea6.s3.amazonaws.com github-production-release-asset-2e65be.s3.amazonaws.com insights.github.com wss://alive.github.com api.githubcopilot.com api.individual.githubcopilot.com api.business.githubcopilot.com api.enterprise.githubcopilot.com; font-src github.githubassets.com; form-action 'self' github.com gist.github.com copilot-workspace.githubnext.com objects-origin.githubusercontent.com; frame-ancestors 'none'; frame-src viewscreen.githubusercontent.com notebooks.githubusercontent.com; img-src 'self' data: blob: github.githubassets.com media.githubusercontent.com camo.githubusercontent.com identicons.github.com avatars.githubusercontent.com private-avatars.githubusercontent.com github-cloud.s3.amazonaws.com objects.githubusercontent.com release-assets.githubusercontent.com secured-user-images.githubusercontent.com/ user-images.githubusercontent.com/ private-user-images.githubusercontent.com opengraph.githubassets.com copilotprodattachments.blob.core.windows.net/github-production-copilot-attachments/ github-production-user-asset-6210df.s3.amazonaws.com customer-stories-feed.github.com spotlights-feed.github.com objects-origin.githubusercontent.com *.githubusercontent.com; manifest-src 'self'; media-src github.com user-images.githubusercontent.com/ secured-user-images.githubusercontent.com/ private-user-images.githubusercontent.com github-production-user-asset-6210df.s3.amazonaws.com gist.github.com; script-src github.githubassets.com; style-src 'unsafe-inline' github.githubassets.com; upgrade-insecure-requests; worker-src github.githubassets.com github.com/assets-cdn/worker/ github.com/assets/ gist.github.com/assets-cdn/worker/
server: github.com
content-encoding: gzip
accept-ranges: bytes
set-cookie: _gh_sess=76htiXE1C%2F8b6zg5HL91ulutZar%2FheUidW4GTqZz%2FaH0I74ihniKoDm3ih5BX4AtqeuNsr%2FOQJ0%2B15ZX9xoYPVZFhQxVgkE4Ci6Dy394Xn3iyUgw5fU3A3PN6fixDRTZBfUzxvdoxalEcZ6y%2B9SH0kLWmLKsz4NBnwFFHD2R2RVeFOHsHAdfzbeXYlWiV4N%2F%2FpWB3E7PxKVSpKgDv3HaSI1D1fsrW7VcxQ3u4HrBxNz453%2FcVwglLkhhN%2FukEioM5PqvpU5C9NKkrUZXd7D61g%3D%3D--VTbGzOlfsMMM2e35--XclnmtN8mlUP%2FQ3cyxMP3g%3D%3D; Path=/; HttpOnly; Secure; SameSite=Lax
set-cookie: _octo=GH1.1.1450638946.1752911093; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 07:44:53 GMT; Secure; SameSite=Lax
set-cookie: logged_in=no; Path=/; Domain=github.com; Expires=Sun, 19 Jul 2026 07:44:53 GMT; HttpOnly; Secure; SameSite=Lax
x-github-request-id: E5BE:110E0E:239CD8:2DA626:687B4CF5
GitHub - wg/epgsql: Erlang PostgreSQL client
Skip to content
Navigation Menu
{{ message }}
-
Notifications
You must be signed in to change notification settings - Fork 87
Erlang PostgreSQL client
License
wg/epgsql
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Erlang PostgreSQL Database Client * Connect {ok, C} = pgsql:connect(Host, [Username], [Password], Opts). Host - host to connect to. Username - username to connect as, defaults to $USER. Password - optional password to authenticate with. Opts - property list of extra options. Supported properties: + {database, String} + {port, Integer} + {ssl, Atom} true | false | required + {ssl_opts, List} see ssl application docs in OTP + {timeout, Integer} milliseconds, defaults to 5000 + {async, Pid} see Asynchronous Messages section {ok, C} = pgsql:connect("localhost", "username", [{database, "test_db"}]). ok = pgsql:close(C). The timeout parameter will trigger an {error, timeout} result when the server fails to respond within Timeout milliseconds. This timeout applies to the initial connection attempt and any subsequent queries. * Simple Query {ok, Columns, Rows} = pgsql:squery(C, "select ..."). {ok, Count} = pgsql:squery(C, "update ..."). {ok, Count, Columns, Rows} = pgsql:squery(C, "insert ... returning ..."). {error, Error} = pgsql:squery(C, "invalid SQL"). Columns - list of column records, see pgsql.hrl for definition. Rows - list of tuples, one for each row. Count - integer count of rows inserted/updated/etc The simple query protocol returns all columns as text (Erlang binaries) and does not support binding parameters. * Extended Query {ok, Columns, Rows} = pgsql:equery(C, "select ...", [Parameters]). {ok, Count} = pgsql:equery(C, "update ...", [Parameters]). {ok, Count, Columns, Rows} = pgsql:equery(C, "insert ... returning ...", [Parameters]). {error, Error} = pgsql:equery(C, "invalid SQL", [Parameters]). Parameters - optional list of values to be bound to $1, $2, $3, etc. The extended query protocol combines parse, bind, and execute using the unnamed prepared statement and portal. A "select" statement returns {ok, Columns, Rows}, "insert/update/delete" returns {ok, Count} or {ok, Count, Columns, Rows} when a "returning" clause is present. When an error occurs, all statements result in {error, #error{}}. PostgreSQL's binary format is used to return integers as Erlang integers, floats as floats, bytea/text/varchar columns as binaries, bools as true/false, etc. For details see pgsql_binary.erl and the Data Representation section below. * Parse/Bind/Execute {ok, Statement} = pgsql:parse(C, [StatementName], Sql, [ParameterTypes]). StatementName - optional, reusable, name for the prepared statement. ParameterTypes - optional list of PostgreSQL types for each parameter. For valid type names see pgsql_types.erl. ok = pgsql:bind(C, Statement, [PortalName], ParameterValues). PortalName - optional name for the result portal. {ok | partial, Rows} = pgsql:execute(C, Statement, [PortalName], [MaxRows]). {ok, Count} = pgsql:execute(C, Statement, [PortalName]). {ok, Count, Rows} = pgsql:execute(C, Statement, [PortalName]). PortalName - optional portal name used in bind/4. MaxRows - maximum number of rows to return (0 for all rows). execute returns {partial, Rows} when more rows are available. ok = pgsql:close(C, Statement). ok = pgsql:close(C, statement | portal, Name). ok = pgsql:sync(C). All functions return {error, Error} when an error occurs. * Data Representation null = null bool = true | false char = $A | binary intX = 1 floatX = 1.0 date = {Year, Month, Day} time = {Hour, Minute, Second.Microsecond} timetz = {time, Timezone} timestamp = {date, time} timestamptz = {date, time} interval = {time, Days, Months} text = <<"a">> varchar = <<"a">> bytea = <<1, 2>> array = [1, 2, 3] record = {int2, time, text, ...} (decode only) * Errors Errors originating from the PostgreSQL backend are returned as {error, #error{}}, see pgsql.hrl for the record definition. epgsql functions may also return {error, What} where What is one of the following: {unsupported_auth_method, Method} - required auth method is unsupported timeout - request timed out closed - connection was closed sync_required - error occured and pgsql:sync must be called * Asynchronous Messages PostgreSQL may deliver two types of asynchronous message: "notices" in response to notice and warning messages generated by the server, and "notifications" which are generated by the LISTEN/NOTIFY mechanism. Passing the {async, Pid} option to pgsql:connect will result in these async messages being sent to the specified process, otherwise they will be dropped. Message formats: {pgsql, Connection, {notification, Channel, Pid, Payload}} Connection - connection the notification occured on Channel - channel the notification occured on Pid - database session pid that sent notification Payload - optional payload, only available from PostgreSQL >= 9.0 {pgsql, Connection, {notice, Error}} Connection - connection the notice occured on Error - an #error{} record, see pgsql.hrl
About
Erlang PostgreSQL client
Resources
License
Security policy
Stars
Watchers
Forks
Packages 0
No packages published
You can’t perform that action at this time.