Python - sql()
This is reference documentation for the Nitric Python SDK. To learn about SQL Databases in Nitric start with the SQL docs.
Creates a reference to a SQL database.
from nitric.resources import sqldatabase = sql("database")
Parameters
- Name
name- Required
- Required
- Type
- string
- Description
The unique name of this database within the project.
- Name
migrations- Optional
- Optional
- Type
- string
- Description
Points to the location of migration files, prefixed with
file://, or a migration dockerfile, prefixed withdockerfile://.
Examples
Create a reference to a database
from nitric.resources import sqldatabase = sql("database")
With a migrations directory
from nitric.resources import sqldatabase = sql("database", migrations="file://migrations")
With a migrations dockerfile
from nitric.resources import sqldatabase = sql("database", migrations="dockerfile://migrations.dockerfile")
See also
Have feedback on this page?
Open GitHub IssueLast updated on Jan 5, 2026