Mercurial > repos > greg > unique_mlg_id
comparison unique_mlg_id.py @ 1:6c10123cb4a7 draft default tip
Uploaded
author | greg |
---|---|
date | Wed, 11 Dec 2024 16:28:27 +0000 |
parents | c39c543605a2 |
children |
comparison
equal
deleted
inserted
replaced
0:c39c543605a2 | 1:6c10123cb4a7 |
---|---|
2 import argparse | 2 import argparse |
3 import sys | 3 import sys |
4 | 4 |
5 import psycopg2 | 5 import psycopg2 |
6 | 6 |
7 from sqlalchemy import MetaData, create_engine | 7 from sqlalchemy import create_engine |
8 from sqlalchemy.engine.url import make_url | 8 from sqlalchemy.engine.url import make_url |
9 | 9 |
10 | 10 |
11 class UniqueMGLIDGenerator(object): | 11 class UniqueMGLIDGenerator(object): |
12 def __init__(self): | 12 def __init__(self): |
14 self.conn = None | 14 self.conn = None |
15 self.parse_args() | 15 self.parse_args() |
16 self.outfh = open(self.args.output, "w") | 16 self.outfh = open(self.args.output, "w") |
17 self.connect_db() | 17 self.connect_db() |
18 self.engine = create_engine(self.args.database_connection_string) | 18 self.engine = create_engine(self.args.database_connection_string) |
19 self.metadata = MetaData(self.engine) | |
20 | 19 |
21 def parse_args(self): | 20 def parse_args(self): |
22 parser = argparse.ArgumentParser() | 21 parser = argparse.ArgumentParser() |
23 parser.add_argument('--database_connection_string', dest='database_connection_string', help='Postgres database connection string'), | 22 parser.add_argument('--database_connection_string', dest='database_connection_string', help='Postgres database connection string'), |
24 parser.add_argument('--output', dest='output', help='Output dataset'), | 23 parser.add_argument('--output', dest='output', help='Output dataset'), |