Get current db user
()
| 86 | |
| 87 | |
| 88 | def get_current_user(): |
| 89 | """ |
| 90 | Get current db user |
| 91 | """ |
| 92 | try: |
| 93 | with ENGINE.connect() as connection: |
| 94 | connection = connection.execution_options( |
| 95 | postgresql_readonly=True |
| 96 | ) |
| 97 | with connection.begin(): |
| 98 | sql_text = text(f"""SELECT CURRENT_USER;""") |
| 99 | result = connection.execute(sql_text) |
| 100 | rows = [list(r) for r in result.all()] |
| 101 | return rows[0][0] |
| 102 | |
| 103 | except Exception as e: |
| 104 | print(e) |
| 105 | return None |
| 106 | |
| 107 | |
| 108 | def save_tables_metadata_to_db(): |