How to I access the database tables?

Hello,

I’m developing a plugin and I need to check the database table values.

How do I do that?

I’m using vscode remoted to wsl.

Thanks!

Ideally you use indico shell and query things through the models, e.g. User.query.all() to get all users.

If you really want to access the database directly, open a shell inside WSL and use psql to get a postgres CLI where you can run SQL. Note that most tables are inside schemas, so you’d have to query e.g. SELECT * FROM users.users; to get all users.

Thanks for the prompt help, do you happen to know the database name? Do I need additional permissions?

I am getting the error that database does not exist on terminal, even though I’m able to successfully able start the indico postgres database by providing username and password while booting up indico.

I’m also registered as an administrator on indico local dev instance.

You specified the database name when setting up Indico - but you can check indico.conf. Most likely it’s called indico.

Thanks, the database name is indeed indico. but when I try to use the \dt command to list all the tables, all I get is a single result -

List of relations
 Schema |      Name       | Type  |  Owner   
--------+-----------------+-------+----------
 public | alembic_version | table | my_name
(1 row)

and on querying it just a single column -

indico-> \d alembic_version
                    Table "public.alembic_version"
   Column    |         Type          | Collation | Nullable | Default 
-------------+-----------------------+-----------+----------+---------
 version_num | character varying(32) |           | not null | 
Indexes:
    "alembic_version_pkc" PRIMARY KEY, btree (version_num)

i’m not able to understand this database design… appreciate any help.

See my comment regarding the schemas - using \dt *.* should show you all the tables.

A useful hint if you implement a plugin: Avoid using raw sql as much as possible, instead find the right models ( either use indico shell or read the source) and create new tables with slqalchemy/alembic, you can check e.g. indico-plugins-cern/outlook/indico_outlook at master · indico/indico-plugins-cern · GitHub how that would look).

Thank you, I was able to check the data I needed.