Package: dr-data
Doctor Data (beta)This is a beta version of this tool. Please submit any issueshereusage:dr-data[-h][-transplant][-sourceSOURCE][-destinationDESTINATION][-inject][-rowsROWS][-biopsy][-exportEXPORT][-cleanse][-configCONFIG]Dr.DataisadatabaseutilitytoolthatcanpopulaterandomdatabasedonyourschemaorcanimportcustomCSVdata.Seeoptionsbelow

optionalarguments:-h,--helpshowthishelpmessageandexit-transplantInsertoneorallCSVfilestotable-sourceSOURCEUsedinconjuctionswith`transplant`TheCSVsourcefileordirectory.ifdirectory,csvfilenamesneedtomatchtablenames-destinationDESTINATIONUsedinconjuctionswith`transplant`and`source`.if`source`isafile.destinationTABLEisrequired-injectInsertsoneormanyrandomlyregeneratedrows-rowsROWSUsedinconjuctionwith`inject`.Howmayrowsdoyouwanttoloadpertableinthedatabase,defaultissetinconfiguration-biopsyExplicitlyexportsaschemaandtableinsertion-orderJSONfiles-exportEXPORTUsedinconjunctionwith`biopsy.ThedirectoryPATHtoexporttheJSONfiles-cleanseTruncatesallthevaluesinthedatabase,WARNINGthiswilldeletealldata!-configCONFIGconfigurationfileorsetDRDATA_CONFIG=<path>envvariablePrerequisitepython 3.9.1Works currently only with PostgreSQL 13+Installationpipinstalldr-dataUsageCreate adr_data.jsonfile with these values and setDRDATA_CONFIG=<path>env variable or using-config=<path>parameter{"db":{"host":"localhost","database":"<db_name>","user":"<db_user>","password":"<db_password>","port":"5432"},"defaults":{"rows":25}}Then run one of the procedure commands (-inject, -transplant, -cleanse, -biopsy)CLI ExamplesExample 1:-injectrandom row data into the databasedr-data-inject# generates a default of 25 rowsdr-data-inject-rows=100Example 2:-transplantdirectory with CSV files (multiple CSV files)
Note: CSV columns need to be named the name as the database column names.dr-data-transplant-source=/path/to/source/directoryExample 3:-transplantone CSV files (single CSV file)
Note: CSV columns need to be named the name as the database column names.dr-data-transplant-source=</path/to/source/file.csv>-destination=<table_name>Example 4:-biopsythe database, produces a schema.json and insertion-order-schema.json filesdr-data-biopsy-export=</path/to/export/directory/>Example 5:-cleansethe database of all data.
Warning: This can't be undone.dr-data-cleanseSDK ExamplesExample 1: UsingBiopsyclassfromdr_data.biopsyimportBiopsyconfiguration={...}schema=Biopsy(configuration).execute_cmd()Example 2: UsingInjectclassfromdr_data.biopsyimportBiopsyfromdr_data.injectimportInjectconfiguration={...}rows=25schema=Biopsy(configuration).execute_cmd()inject=Inject(schema,configuration)inject.execute_cmd(rows)Example 3: UsingTransplantclass (file import)fromdr_data.transplantimportTransplantconfiguration={...}source_file="/path/to/foobar.csv"destination_table="foobar"transplant=Transplant(configuration)transplant.execute_file_cmd(source_file,destination_table)Example 4: UsingTransplantclass (directory import)fromdr_data.transplantimportTransplantconfiguration={...}source_directory="/path/to/foobar"transplant=Transplant(configuration)transplant.execute_directory_cmd(source_directory)Example 5: UsingRandomsclass (optional usage)fromdr_data.randomsimportRandomsrandom_hash=Randoms.get_hash(10)# get random hash valuerandom_datetime=Randoms.get_datetime()# get random datetimerandom_datetime_with_timezone=Randoms.get_datetime_with_timezone()# get random datetime with timezonerandom_number=Randoms.get_datetime_with_timezone()# get random numberrandom_boolean=Randoms.get_boolean()# get random booleanDevelopment Setupgitclonehttps://github.com/sunnysidesounds/dr_datacddr_data
python-mvenv.
venv/bin/pipinstall-e.
venv/bin/dr-data-h