Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

psql.py 727 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
  1. """
  2. Spawn a PSQL shell with configuration from the DB configuration.
  3. Usage:
  4. psql.py [args]
  5. """
  6. import os
  7. import sys
  8. import re
  9. import time
  10. import hashlib
  11. import subprocess as sp
  12. from pathlib import Path
  13. from datetime import timedelta
  14. from typing import NamedTuple, List
  15. from bookdata import script_log
  16. from bookdata import db, tracking
  17. _log = script_log(__name__)
  18. config = db.DBConfig.load()
  19. os.environ['PGHOST'] = config.host
  20. os.environ['PGDATABASE'] = config.database
  21. if config.port:
  22. os.environ['PGPORT'] = config.port
  23. if config.user:
  24. os.environ['PGUSER'] = config.user
  25. if config.password:
  26. os.environ['PGPASSWORD'] = config.password
  27. _log.info('spawning psql')
  28. sp.run(['psql'] + sys.argv[1:], check=True)
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...