Skip to content

Setting Up PostgreSQL

Yanis ♨️ edited this page Jan 25, 2024 · 1 revision

Setting Up a PostgreSQL Database

Before you can run Yasuho, you need to set up a PostgreSQL database to store configuration data and other information. Here's a step-by-step guide on how to do it:

  1. Install PostgreSQL: If you haven't already, download and install PostgreSQL on your server or local machine. You can find the official download and installation instructions on the PostgreSQL website.

  2. Create a Database: After installing PostgreSQL, create a new database for Yasuho. You can do this using the createdb command or through a graphical tool like pgAdmin. For example:

    createdb yasuho_db
    
  3. Set Up User and Password: Create a user and assign a password to it. This user will be used to access the Yasuho database. You can create a user using the createuser command or a graphical tool. For example:

    createuser yasuho_user --pwprompt
    

    You will be prompted to enter a password for the user.

  4. Grant Privileges: Grant necessary privileges to the user on the Yasuho database:

    psql -d yasuho_db
    GRANT ALL PRIVILEGES ON DATABASE yasuho_db TO yasuho_user;
    \q
    
  5. Update Configuration: In your bot.ini file, make sure you have the correct PostgreSQL database URI. Replace the PostgreSQL value with your database connection string:

    [Database]
    PostgreSQL = postgresql://yasuho_user:your_password@your_database_host/your_database_name

    Replace yasuho_user, your_password, your_database_host, and your_database_name with the appropriate values.

  6. Test the Connection: To verify that your bot can connect to the database, run Yasuho. If there are no errors related to the database connection, you have successfully set up PostgreSQL for Yasuho.

  7. Migrate and Initialize: Depending on your bot's needs, you may need to run database migrations and initialize tables. Refer to your bot's documentation for specific instructions on database setup.

Now your Yasuho bot should be able to connect to the PostgreSQL database you've configured. Make sure to keep your database credentials and connection string secure, and consider using environment variables to store sensitive information.

Clone this wiki locally