{"id":19065264,"url":"https://github.com/hackersandslackers/psycopg2-tutorial","last_synced_at":"2025-04-28T11:27:26.948Z","repository":{"id":44556345,"uuid":"246958993","full_name":"hackersandslackers/psycopg2-tutorial","owner":"hackersandslackers","description":":elephant: :floppy_disk: Tutorial for connecting to a Postgres database in Python.","archived":false,"fork":false,"pushed_at":"2024-12-15T19:14:53.000Z","size":456,"stargazers_count":21,"open_issues_count":18,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T11:27:21.031Z","etag":null,"topics":["database","postgres","postgresql","python","python-3","tutorial"],"latest_commit_sha":null,"homepage":"https://hackersandslackers.com/psycopg2-postgres-python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hackersandslackers.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://www.buymeacoffee.com/hackersslackers"]}},"created_at":"2020-03-13T00:50:05.000Z","updated_at":"2024-11-13T14:26:08.000Z","dependencies_parsed_at":"2024-10-17T23:38:37.522Z","dependency_job_id":"81839cfe-53f2-425d-ae27-6c6775865375","html_url":"https://github.com/hackersandslackers/psycopg2-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackersandslackers%2Fpsycopg2-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackersandslackers%2Fpsycopg2-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackersandslackers%2Fpsycopg2-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hackersandslackers%2Fpsycopg2-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hackersandslackers","download_url":"https://codeload.github.com/hackersandslackers/psycopg2-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251303898,"owners_count":21567769,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","postgres","postgresql","python","python-3","tutorial"],"created_at":"2024-11-09T00:49:15.764Z","updated_at":"2025-04-28T11:27:26.910Z","avatar_url":"https://github.com/hackersandslackers.png","language":"Python","readme":"# Psycopg2 Tutorial\n\n![Python](https://img.shields.io/badge/Python-v3.8-blue.svg?logo=python\u0026longCache=true\u0026logoColor=white\u0026colorB=5e81ac\u0026style=flat-square\u0026colorA=4c566a)\n![Psycopg2-Binary](https://img.shields.io/badge/Psycopg2--binary-v2.8.4-blue.svg?longCache=true\u0026logo=postgresql\u0026longCache=true\u0026style=flat-square\u0026logoColor=white\u0026colorB=5e81ac\u0026colorA=4c566a)\n![GitHub Last Commit](https://img.shields.io/github/last-commit/google/skia.svg?style=flat-square\u0026colorA=4c566a\u0026colorB=a3be8c)\n[![GitHub Issues](https://img.shields.io/github/issues/hackersandslackers/psycopg2-tutorial.svg?style=flat-square\u0026colorA=4c566a\u0026colorB=ebcb8b\u0026logo=Github)](https://github.com/hackersandslackers/psycopg2-tutorial/issues)\n[![GitHub Stars](https://img.shields.io/github/stars/hackersandslackers/psycopg2-tutorial.svg?style=flat-square\u0026colorA=4c566a\u0026colorB=ebcb8b\u0026logo=Github)](https://github.com/hackersandslackers/psycopg2-tutorial/stargazers)\n[![GitHub Forks](https://img.shields.io/github/forks/hackersandslackers/psycopg2-tutorial.svg?style=flat-square\u0026colorA=4c566a\u0026colorB=ebcb8b\u0026logo=Github)](https://github.com/hackersandslackers/psycopg2-tutorial/network)\n\n![Psycopg2-Tutorial](https://github.com/hackersandslackers/psycopg2-tutorial/blob/master/.github/psycopg2@2x.jpg?raw=true)\n\nSource code for the accompanying tutorial found here: https://hackersandslackers.com/psycopg2-postgres-python/\n\nConnect to a PostgreSQL database and execute queries in Python using the Psycopg2 library using this tutorial. This script looks for **.sql** files stored in the **/queries** directory, and executes them against a Postgres database.\n\n\n## Getting Started\n\n**Installation via `requirements.txt`**:\n\n```shell\n$ git clone https://github.com/hackersandslackers/psycopg2-tutorial.git\n$ cd psycopg2-tutorial\n$ python3 -m venv myenv\n$ source myenv/bin/activate\n$ pip3 install -r requirements.txt\n$ python3 main.py\n```\n\n**Installation via [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/)**:\n\n```shell\n$ git clone https://github.com/hackersandslackers/psycopg2-tutorial.git\n$ cd psycopg2-tutorial\n$ pipenv shell\n$ pipenv update\n$ python3 main.py\n```\n\n**Installation via [Poetry](https://python-poetry.org/)**:\n\n```shell\n$ git clone https://github.com/hackersandslackers/psycopg2-tutorial.git\n$ cd psycopg2-tutorial\n$ poetry shell\n$ poetry update\n$ poetry run\n```\n\n## Usage\n\nReplace the values in **.env.example** with your values and rename this file to **.env**:\n\n* `DATABASE_USERNAME`: The username used to connect to your Postgres database.\n* `DATABASE_PASSWORD`: Password for the above user.\n* `DATABASE_HOST`: The hostname of your database (ie: localhost).\n* `DATABASE_NAME`: The name of your \"database\" (the database inside your database - why isn't there a better term for this?).\n* `DATABASE_PORT`: Port of your Postgres database (default is 5432).\n\n*Remember never to commit secrets saved in .env files to Github.*\n\n-----\n\n**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content.\n","funding_links":["https://www.buymeacoffee.com/hackersslackers"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackersandslackers%2Fpsycopg2-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhackersandslackers%2Fpsycopg2-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhackersandslackers%2Fpsycopg2-tutorial/lists"}