Database Setup
Before using the Linns Data Pipeline and its associated models, you need to set up the database where the product data will be stored. Follow these steps to configure and initialize the database:
1. Install PostgreSQL:
If you haven't already, install PostgreSQL on your system. You can download and install PostgreSQL from the official website: PostgreSQL Downloads.
2. Create a Database:
- Open a command prompt or terminal and log in to PostgreSQL using a superuser account (usually "postgres"):
- Create a new database for the Linns Data Pipeline (replace 'your_database_name' with your preferred database name):
3. Configure Environment Variables:
The pipeline relies on environment variables to establish a connection to the database. Ensure you have the following environment variables set:
- USERNAME: Your database username.
- PASSWORD: Your database password.
- DB: The name of the database you created in the previous step.
- HOST: The database host (usually localhost).
4. Initialize the Database Tables:
- Navigate to the directory where your project code is located.
- Run the Python script to create the necessary tables in the database:
This script will use the SQLAlchemy models to create the tables with the defined schema in the PostgreSQL database.
5. Verify the Database:
You can use a PostgreSQL client or command-line tools like psql to verify that the tables have been created and populated correctly:
- Connect to your database using psql or your preferred PostgreSQL client:
- List the tables in the database:
This should display a list of tables including Inventory, Locations, StockLevels, and others, confirming that the database setup was successful. With the database set up, you can now use the Linns Data Pipeline to manage and analyze product data effectively.
View the models Setup here: Models