Skip to content

Commit 01cfc7a

Browse files
committed
refactoring
1 parent 28d1926 commit 01cfc7a

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

src/rowgen/main.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ def get_parser():
2626
action="store_true",
2727
help="Executes insert statements into the database directly.",
2828
)
29+
parser.add_argument(
30+
"--rows",
31+
default=20,
32+
help="Enter the number of rows you want to be filled with generative data.",
33+
)
2934
parser.add_argument("--apikey", help="Enter your huggingface_hub api key.")
3035
return parser
3136

@@ -44,16 +49,17 @@ def main():
4449
else:
4550
db_url = "{args.db_type}://{args.user}:{args.password}@{args.host}:{args.port}/{args.database}"
4651

52+
rows = args.rows
53+
4754
dbc = DBconnect(db_url)
4855
hf = HFapi(api_key=api_key)
49-
ai_sql_response = hf.prompt_fake_data(dbc.table_columns, 20)
56+
ai_sql_response = hf.prompt_fake_data(dbc.table_columns, rows)
5057
sql_statements = parse_sql_from_code_block(ai_sql_response)
58+
5159
# execute
5260
if args.execute:
5361
sql_statements = sql_statements.split("\n")
54-
engine = create_engine(
55-
"sqlite:///testrowgendb.sqlite"
56-
) # replace with your DB URL
62+
engine = create_engine("sqlite:///testrowgendb.sqlite")
5763
with engine.connect() as connection:
5864
for sql in sql_statements:
5965
connection.execute(text(sql))

src/rowgen/testrowgendb.sqlite

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)