This project provides a simple interface to manage image uploads and displays using a PostgreSQL database. It allows you to insert images from a directory into the database and display them on demand.
Before running this project, ensure you have the following installed:
- Python 3.7 or higher
- PostgreSQL database server
- Python packages listed in the
requirements.txtfile (asyncio,psycopg3,PIL) - A reference directory to store the images. This directory should be created before running the project.
- Clone the repository:
git clone https://github.com/sako-ranj/psycopg3-python.git
cd psycopg3-python- Install the required Python packages:
pip install -r requirements.txt- Set up the PostgreSQL database and configure the database connection in
config.py:
DATABASE_CONFIG = {
'database': 'your_database_name',
'user': 'your_username',
'password': 'your_password',
'host': 'localhost'
}
IMAGE_PATH = 'path_to_your_image_directory' # e.g., 'references/'Replace 'your_database_name', 'your_username', 'your_password', and 'path_to_your_image_directory' with your actual database credentials and image directory path.
To use the Image Database Manager, follow these steps:
-
Ensure your PostgreSQL server is running.
-
Open a terminal or command prompt and navigate to the project directory.
-
Run the main script with one of the following commands:
-
To insert all images from the specified directory into the database:
python main.py insert
-
To display all images stored in the database:
python main.py display
-
Note: Make sure to replace python with the appropriate command if you're using a virtual environment.
- Thanks to the developers of
psycopg3andPILfor their contributions to the Python ecosystem. - Special thanks to the community for feedback and support.
Feel free to customize the project further based on your needs or contribute to its development. Enjoy managing your image database!