Details

- DatabaseReference[…] includes information on how to connect to a database, but does not actually perform the connection. The connection is automatically performed by functions like RelationalDatabase, as well as by database querying functions such EntityValue.
- In DatabaseReference[URL["url"]], "url" is typically of the form "backend://user:password@host:port/name".
- In DatabaseReference[File["path"]], "path" is the path to an SQLite database file.
- In DatabaseReference[assoc], typical elements of assoc include:
-
"Backend" the type of SQL backend used "Name" the name of the database, or path to it "Host" the host serving the database "Port" the server port through which to access the database "Username" the username used to authenticate the database "Password" the password used to authenticate the database - Possible values for "Backend" include "SQLite", "PostgreSQL", "MySQL", "MicrosoftSQL", "Oracle".
- For file-based databases such as SQLite, "Name" gives the path to the file containing the database. If "Name" is not provided, an in-memory database is used.
- For server-based databases, "Name" gives the name of the database at the specified endpoint.
- For file-based databases, no values need to be specified for "Host" and "Port".
- For server-based databases, "Host" can be a network host name or an IP address, specified with a string or using an IPAddress object.
- If no value for "Port" is specified, a default for each type of backend will be used.
- DatabaseReference[…][prop] gives information about the database being referenced.
- The property prop can be any of the elements that can be supplied in DatabaseReference[assoc].
Examples
open allclose allBasic Examples (4)Summary of the most common use cases
Construct a DatabaseReference from a file:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-whmgd1

Construct a DatabaseReference from a URL:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-pgvlrw

Construct a DatabaseReference from an Association:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-l0u85z

Execute SQL commands using ExternalEvaluate:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-j4gt81

Scope (1)Survey of the scope of standard use cases
Extract properties from a DatabaseReference:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-emx228


https://wolfram.com/xid/0bc6ixhb1ft1p1e-f3xd6f

Multiple properties can be extracted at once:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-xxvs8c

Applications (4)Sample problems that can be solved with this function
Use in conjunction with RelationalDatabase to extract the schema of a database:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-ury1qj

Construct an EntityStore from the RelationalDatabase object:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-fbzaue

Register the EntityStore:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-eshjaz


https://wolfram.com/xid/0bc6ixhb1ft1p1e-m6brmt

Open a database connection by using StartExternalSession:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-hctz76


https://wolfram.com/xid/0bc6ixhb1ft1p1e-nt76oa

Delete the session to disconnect:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-2amn4m
Use ExternalEvaluate to open a connection, run a query and close the connection:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-t75x55

DatabaseReference can also represent an in-memory SQLite database:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-20uc3

All operations done over an in-memory session are lost at the end of the ExternalEvaluate call:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-zfcecb


https://wolfram.com/xid/0bc6ixhb1ft1p1e-7qce5o

Properties & Relations (1)Properties of the function, and connections to other functions
Construct a DatabaseReference pointing to a file:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-laiezk

Connect manually to the database:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-89cjqf


https://wolfram.com/xid/0bc6ixhb1ft1p1e-rofid9

Possible Issues (1)Common pitfalls and unexpected behavior
A DatabaseReference does not guarantee the existence of the database:

https://wolfram.com/xid/0bc6ixhb1ft1p1e-lkzhcj

https://wolfram.com/xid/0bc6ixhb1ft1p1e-rph49t
Wolfram Research (2019), DatabaseReference, Wolfram Language function, https://reference.wolfram.com/language/ref/DatabaseReference.html.
Text
Wolfram Research (2019), DatabaseReference, Wolfram Language function, https://reference.wolfram.com/language/ref/DatabaseReference.html.
Wolfram Research (2019), DatabaseReference, Wolfram Language function, https://reference.wolfram.com/language/ref/DatabaseReference.html.
CMS
Wolfram Language. 2019. "DatabaseReference." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DatabaseReference.html.
Wolfram Language. 2019. "DatabaseReference." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/DatabaseReference.html.
APA
Wolfram Language. (2019). DatabaseReference. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DatabaseReference.html
Wolfram Language. (2019). DatabaseReference. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DatabaseReference.html
BibTeX
@misc{reference.wolfram_2025_databasereference, author="Wolfram Research", title="{DatabaseReference}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/DatabaseReference.html}", note=[Accessed: 09-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_databasereference, organization={Wolfram Research}, title={DatabaseReference}, year={2019}, url={https://reference.wolfram.com/language/ref/DatabaseReference.html}, note=[Accessed: 09-May-2025
]}