Oracle Developer's Python Starter Kit for VS Code Remote - Containers Extension
Visual Studio Code (VS Code) provides extensions for working with remote machines. This includes the Remote - Containers that allows developers to use Docker containers as a self-contained development environment.
Using containers has many benefits. It allows developers to maintain a consistent development environment that can be easily moved or copied onto other workstations or by other developers. It creates a sandbox environment that shields your host system from unnecessary software components, that is especialy crucial when experimenting and documenting.
Using this starter kit, an Oracle Developer can quickly get started with developing in Python, within a development container (devcontainer).
- Microsoft Visual Studio Code [Download]
- Remote - Container extension - Install the Remote Development pack or just the extension.
- Docker - Follow the instructions to install Docker Community Edition for your host operating system.
The starter kit runs a Docker container with the following components for Python development:
- Oracle Instant Client Release 19.3
- Oracle SQL*Plus
- Python 3.x
- Oracle Cloud Infrastructure (OCI) Python SDK
- Microsoft's Python extension for VS Code
Place any additional Python libraries required by the project in the
requirements.txt file. Do not include cx_Oracle as it is already included in the Docker build. Packages should be available on the Python Package Index.
The devcontainer installs the VS Code extension for Python and configure pylint as the linter. Add any additional extensions required in the
extensions attribute in the
devcontainer.json file. For example, this adds the Language PL/SQL extension:
"extensions": [ "ms-python.python", "xyz.plsql-language" ]
- Build a Docker image for running an Oracle Database using the instructions found here. Alternatively, for Linux and Mac users, there are scripts in the docker-apex-stack that will facilitate the process and at the same time, provision a full Oracle Application Express (APEX) stack.
- Run a container using the image and attach it to a Docker network.
- Clone the project:
$ git clone https://github.com/fuzziebrain/vscode-remote-oradev-python.git
- Modify the Docker network to attach to, in the
devcontainer.json. For example, the following parameter attaches the devcontainer to the axer_network typically used with the docker-apex-stack:
- If a port is required to be exposed, add it to the attribute
appPort. For example, Flask run on port
"appPort": [ 5000 ]
- Open the project directory in VS Code. It should detect the devcontainer and ask whether to reload the folder from within the container.
Run the command Remote Containers: Reopen Folder in Container
Modifying the Devcontainer
Customise the Docker container if necessary. To rebuild the container, run the command Remote Containers: Rebuild Container. This command is only available when the folder is opened in a devcontainer.
A debug configuration has been created. See
Connecting to the Oracle Database
Developers are encouraged to store database credentials safely in encrypted Oracle Wallets, as oppose to storing them in plaintext either within the Python script or as environment variables. Follow the Oracle Database Connection with Oracle Wallet guide.
Support for Oracle Cloud Infrastructure
The beauty of Open Source is that we can learn and build on top of previous knowledge shared by others. I wish to thank the following projects that have guided the creation of this starter kit:
Please see LICENSE.