how to get the database name in postgresql code example
Example 1: get the list of all tables in sql server
SELECT TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_TYPE = 'BASE TABLE' AND TABLE_CATALOG='YOUR_Database_name'
Example 2: get the name of a current script in python
Use __file__. If you want to omit the directory part (which might be present), you can use os.path.basename(__file__)