{"id":13706473,"url":"https://github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool","last_synced_at":"2025-05-05T20:31:29.975Z","repository":{"id":50369504,"uuid":"21479995","full_name":"PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool","owner":"PNNL-Comp-Mass-Spec","description":"Exports SQL Server and Postgres database objects as schema files. Exported objects include tables, views, stored procedures, and functions, plus also database properties including database roles and logins.  The program can also export table data to create SQL files with an Insert Into statement for each row.","archived":false,"fork":false,"pushed_at":"2025-01-24T03:03:49.000Z","size":5467,"stargazers_count":14,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-17T21:18:18.496Z","etag":null,"topics":["postgresql","postgresql-database","sql-server","sql-server-database"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PNNL-Comp-Mass-Spec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"License.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-03T23:34:17.000Z","updated_at":"2025-02-23T07:41:40.000Z","dependencies_parsed_at":"2023-01-31T09:46:13.875Z","dependency_job_id":"921c19f0-51d7-43c7-878e-5c18e2ddf811","html_url":"https://github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PNNL-Comp-Mass-Spec","download_url":"https://codeload.github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252571068,"owners_count":21769770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgresql","postgresql-database","sql-server","sql-server-database"],"created_at":"2024-08-02T22:00:57.380Z","updated_at":"2025-05-05T20:31:29.338Z","avatar_url":"https://github.com/PNNL-Comp-Mass-Spec.png","language":"C#","funding_links":[],"categories":["C# #"],"sub_categories":[],"readme":"# DB Schema Export Tool\r\n\r\nThe DB Schema Export Tool exports SQL Server or PostgreSQL database objects as schema files.\r\nExported objects include tables, views, stored procedures, functions, and synonyms,\r\nplus also database properties including database roles and logins.\r\n\r\nUses integrated authentication or a named user to connect to a Microsoft SQL Server database.\r\n\r\nUses a named user, password, and port to connect to a PostgreSQL database.\r\n\r\n### Continuous Integration\r\n\r\nThe latest version of the application is available for one month on the [AppVeyor CI server](https://ci.appveyor.com/project/PNNLCompMassSpec/db-schema-export-tool/build/artifacts)\r\n\r\n[![Build status](https://ci.appveyor.com/api/projects/status/sdk00tc0l0seupic?svg=true)](https://ci.appveyor.com/project/PNNLCompMassSpec/db-schema-export-tool)\r\n\r\n## Features\r\n\r\nIn addition to creating schema files for tables, views, stored procedures, functions, and synonyms,\r\nthe program can also export table data to create SQL files with an Insert statement for each row.\r\n\r\nThe DB Schema Export Tool has both a command line interface and a GUI mode.\r\nStarting the program without any parameters will show the GUI.\r\n\r\nThe command line interface is useful for automatically exporting schema files on a regular basis.\r\nExample command (wrapped here for readability):\r\n\r\n```\r\nDB_Schema_Export_Tool.exe\r\n  C:\\Cached_DBSchema\r\n  /Server:Proteinseqs\r\n  /DBList:Manager_Control,Protein_Sequences\r\n  /Sync:\"F:\\Projects\\Database_Schema\\DMS\"\r\n  /Git /Commit\r\n  /L /LogDir:Logs\r\n  /Data:ProteinSeqs_Data_Tables.txt\r\n```\r\n\r\n## Console switches\r\n\r\n```\r\nDB_Schema_Export_Tool.exe\r\n SchemaFileDirectory /Server:ServerName\r\n /DB:Database /DBList:CommaSeparatedDatabaseName\r\n [/DBUser:username] [/DBPass:password]\r\n [/PgUser:username] [/PgPass:password] [/PgPort:5432]\r\n [/DirectoryPrefix:PrefixText] [/NoSubdirectory] [/CreateDBDirectories]\r\n [/DataTables:TableDataToExport.txt] [/Map:ColumnMapping.txt]\r\n [/DataSort:PgDumpTableDataSortOrder.txt]\r\n [/TableFilterList] [/SchemaSkipList]\r\n [/ColumnFilter:FileName] [/DateFilter:FileName]\r\n [/NameFilter:FilterSpec]\r\n [/DataExportOrder:FileName]\r\n [/Schema:SchemaName] [/ExistingDDL:SchemaFileName]\r\n [/NoAutoData] [/ExportAllData] [/MaxRows:1000] [/NoData]\r\n [/DisableStatementLogging:true] [/MinLogDuration:5000]\r\n [/DeleteExtraRows] [/ForceTruncate:TableList]\r\n [/DisableTriggers] \r\n [/ScriptLoad] [/ScriptUser:username] [/ScriptDB:Database] \r\n [/ScriptHost:HostName] [/ScriptPort:Port]\r\n [/SnakeCase] [/PgDump] [/KeepPgDumpFile]\r\n [/PgInsert] [/PgInsertChunkSize:50000]\r\n [/ServerInfo] [/NoSchema]\r\n [/Sync:TargetDirectoryPath] [/Git] [/Svn] [/Hg] [/Commit]\r\n [/L] [/LogFile:BaseName] [/LogDir:LogDirectoryPath]\r\n [/Preview] [/Stats] [/Trace]\r\n [/ParamFile:ParamFileName.conf] [/CreateParamFile]\r\n```\r\n\r\n`SchemaFileDirectory` is the path to the directory where the schema files will be saved (aka the output directory)\r\n* Optionally use named parameter `/OutputDir:DirectoryPath`\r\n\r\nTo process a single database, use `/Server` and `/DB`\r\n* The server is assumed to be Microsoft SQL Server\r\n* However, if `/PgUser` is provided (or `PgUser` is defined in the parameter file), will treat as a PostgreSQL server\r\n\r\nUse `/DBList` to process several databases (separate names with commas)\r\n\r\nUse `/DBUser` and `/DBPass` to specify a username and password for connecting to a SQL Server instance\r\n* If not defined, will use Windows Integrated Authentication\r\n\r\nUse `/PgUser` to define the username to use to connect to a PostgreSQL database\r\n\r\nUse `/PgPass` to define the password for the PostgreSQL user\r\n* As described below, you can create a file named `pgpass.conf` at `%APPDATA%\\postgresql` to track passwords for PostgreSQL users\r\n* The format is `server:port:database:username:password`\r\n* `pg_dump.exe` will obtain the password from this file if it exists\r\n* On Linux, the file is stored at `~/.pgpass`\r\n\r\nUse `/PgPort` to specify the port to use for PostgreSQL\r\n* Defaults to 5432\r\n\r\nBy default, a subdirectory named DBSchema__DatabaseName will be created below `SchemaFileDirectory/`\r\n* Customize this prefix text using `/DirectoryPrefix`\r\n\r\nUse `/NoSubdirectory` to disable auto creating a subdirectory for the database being exported\r\n* Note: subdirectories will always be created if you use `/DBList` and specify more than one database\r\n\r\nUse `/CreateDBDirectories:False` to disable creating a subdirectory for the schema files for each database\r\n\r\nUse `/DataTables` or `/Data` to define a text file with table names (one name per line) for which the data\r\nshould be exported. In addition to table names defined in `/Data`, there are default tables\r\nwhich will have their data exported; disable the defaults using `/NoAutoData`\r\n* Also supports a multi-column, tab-delimited format\r\n  * Put `\u003cskip\u003e` in the TargetTableName column to indicate that the table should not be included when using `/ExportAllData`\r\n* The file can also track renamed views\r\n* File format\r\n\r\n| SourceTableName        | TargetSchemaName | TargetTableName       | PgInsert  | KeyColumn(s)      |\r\n|------------------------|------------------|-----------------------|-----------|-------------------|\r\n| T_Analysis_State_Name  | public           | t_analysis_job_state  | true      | job_state_id      |\r\n| T_DatasetRatingName    | public           | t_dataset_rating_name | true      | dataset_rating_id |\r\n| T_Log_Entries          | public           | t_log_entries         | false     |                   |\r\n| T_Job_Events           | cap              | t_job_Events          | false     |                   |\r\n| T_Job_State_Name       | cap              | t_job_state_name      | true      | job               |\r\n| T_Users                | public           | t_users               | true      | user_id           |\r\n| x_T_MgrState           | public           | `\u003cskip\u003e`              |           |                   |\r\n| V_Cell_Culture         | public           | v_biomaterial         |           |                   |\r\n| V_Cell_Culture_Date    | public           | v_biomaterial_date    |           |                   |\r\n\r\n\r\nTables with `PgInsert` set to true will have data insert commands formatted as PostgreSQL compatible\r\n`INSERT INTO` statements using the `ON CONFLICT (key_column) DO UPDATE SET` syntax\r\n* This is only applicable when exporting data from SQL Server\r\n* Use the `KeyColumn(s)` column to specify the primary key (or pair of unique keys) used for determining a conflict\r\n  * Any columns that are not key columns will be updated when a conflict is found\r\n  * If `PgInsert` is true, but the `KeyColumn(s)` column is empty, the program will look for an identity column on the source table\r\n* Example generated SQL:\r\n\r\n```PLpgSQL\r\nINSERT INTO mc.t_mgr_types (mt_type_id, mt_type_name, mt_active)\r\nOVERRIDING SYSTEM VALUE\r\nVALUES\r\n  (1, 'Analysis', 1),\r\n  (2, 'Archive', 0),\r\n  (3, 'Archive Verify', 0),\r\n  (4, 'Capture', 1),\r\n  (5, 'Space', 1),\r\n  (6, 'Data Import', 1)\r\nON CONFLICT (mt_type_id)\r\nDO UPDATE SET\r\n  mt_type_name = EXCLUDED.mt_type_name,\r\n  mt_active = EXCLUDED.mt_active;\r\n\r\n-- Set the sequence's current value to the maximum current ID\r\nSELECT setval('mc.t_mgr_types_mt_type_id_seq', (SELECT MAX(mt_type_id) FROM mc.t_mgr_types));\r\n\r\n-- View the current ID for the sequence\r\nSELECT currval('mc.t_mgr_types_mt_type_id_seq');\r\n```\r\n\r\nUse `/Map` or `/ColumnMap` to define a tab-delimited text file mapping source column names to target column names, by table\r\n* Use keyword `\u003cskip\u003e` in the `TargetColumnName` column to indicate that a source column should not be included in the output file\r\n* If `/SnakeCase` is used to auto-change column names, mappings in this file will override the snake case auto-conversion\r\n* File format:\r\n\r\n| SourceTableName  | SourceColumnName | TargetColumnName |\r\n|------------------|------------------|------------------|\r\n| T_Analysis_Job   | AJ_jobID         | job              |\r\n| T_Analysis_Job   | AJ_start         | start            |\r\n| T_Analysis_Job   | AJ_finish        | finish           |\r\n| t_users          | name_with_prn    | `\u003cskip\u003e`         |\r\n\r\n\r\nUse `/DataSort` (or `/PgDumpDataSort` or `/PgDumpTableDataSortOrder`) to define a tab-delimited text file that defines the columns to use for sorting data exported using PgDump\r\n* The export file will be re-written with data sorted by the specified column numbers (1-based)\r\n* Table names should include the schema, e.g. \"public.t_event_target\" or \"sw.t_job_state_name\"\r\n* Sort_Columns should list the column number (or comma-separated list of column numbers) to sort the data on\r\n  * \"1\" means to sort using the first column\r\n  * \"2, 3\" means to sort using the second column, then the third column\r\n* Values in Sort_Numeric should be True, False, or an empty string\r\n  * True means to assume the data in the first sort column is numeric (integer or double)\r\n  * False is ignored; if any sort column has numbers for every row, it will be sorted as numeric\r\n* File format:\r\n\r\n| Table_Name                           | Sort_Columns   | Sort_Numeric |\r\n|--------------------------------------|----------------|--------------|\r\n| cap.t_automatic_jobs                 | 1, 2           |              |\r\n| cap.t_scripts                        | 2              |              |\r\n| cap.t_scripts_history                | 3, 1           |              |\r\n| cap.t_step_tools                     | 2, 1           |              |\r\n| cap.t_task_state_name                | 1              | True         |\r\n| public.t_analysis_job_state          | 1              | True         |\r\n| public.t_default_psm_job_parameters  | 2, 3, 4, 5, 6  |              |\r\n| public.t_user_operations_permissions | 1, 2           | True         |\r\n| sw.t_job_state_name                  | 1              | True         |\r\n| timetable.task                       | 2, 1           | True         |\r\n                       \r\nUse `/TableFilterList` or `/TableNameFilter` to specify a table name (or comma separated list of names) to restrict table export operations\r\n* This is useful for exporting the data from just a single table (or a few tables)\r\n* This parameter does not support reading names from a file; it only supports actual table names\r\n* If a file was defined via the `/DataTables` parameter, the list of tables loaded from that file will be filtered by this list (matching both SourceTableName and TargetTableName)\r\n\r\nUse `/SchemaSkipList` to specify a schema name (or comma separated list of names) of schema to skip\r\n* This is useful if using partitioned tables\r\n\r\nUse `/ColumnFilter` or `/TableDataColumnFilter` to define a tab-delimited text file that defines columns to skip when exporting data from tables\r\n* The program auto-skips computed columns and timestamp columns when exporting data as PostgreSQL compatible INSERT INTO statements\r\n* File format:\r\n\r\n| Table                  | Column           | Comment                                                                        |\r\n|------------------------|------------------|--------------------------------------------------------------------------------|\r\n| T_Cached_Dataset_Links | DS_RowVersion    | In PostgreSQL, tracked via data type xid; comes from t_dataset.xmin            |\r\n| T_Cached_Dataset_Links | SPath_RowVersion | In PostgreSQL, tracked via data type xid; comes from t_storage_path.xmin       |\r\n| T_EUS_Proposals        | Numeric_ID       | Computed column (redundant here since the program auto-skips computed columns) |\r\n\r\n\r\nUse `/DateFilter` or `/TableDataDateFilter` to define a tab-delimited text file that defines date filters to use when exporting data from tables\r\n* The data file will include the start date in the name, for example: `mc.t_log_entries_Data_Since_2020-01-01.sql`\r\n* File format:\r\n\r\n| SourceTableName          | DateColumnName   | MinimumDate  |\r\n|--------------------------|------------------|--------------|\r\n| T_Event_Log              | Entered          | 2020-01-01   |\r\n| T_Log_Entries            | posting_time     | 2020-01-01   |\r\n| T_ParamValue             | last_affected    | 2020-01-01   |\r\n| T_ParamValue_OldManagers | last_affected    | 2016-01-07   |\r\n\r\n\r\nUse `/NameFilter` to define a filter to apply to exported tables, views, procedures, etc.\r\n* Will only export objects that contain this text in the name\r\n  * This is only applicable when exporting objects from SQL Server\r\n* Use `^` to indicate the object names must start with the text, for example `^Auto` to start with Auto\r\n  * This only works if using a parameter file, since the Windows command line parser removes ^\r\n* Use `$` to indicate the object names must end with the text, for example `Report$` to end with Report\r\n* Other RegEx qualifiers are supported; matches are case insensitive\r\n* Multiple filters can be provided by separating with commas\r\n  * At the command line, surround comma separated lists with double quotes\r\n  * Will not split on commas if the object name filter has square brackets\r\n\r\nUse `/DataExportOrder` to define a text file with table names (one name per line) defining the order that data should be exported from tables\r\n* Should have table names only, without schema\r\n* Tables not listed in this file will have their data exported alphabetically by table name\r\n* If the first line is Table_Name, will assume that it is a header line (and will thus ignore it)\r\n* If `/ScriptLoad` is used to create a shell script for loading data (see below), the data will be loaded in the order specified by the `DataExportOrder` file, followed by tables not listed in the file\r\n  * This is useful for assuring that data is loaded into the database in an order that will guarantee that foreign keys are valid\r\n* For example, given a multi-campus university that tracks graduate students and professors using four tables:\r\n```mermaid\r\ngraph TD;\r\n    T_Campus--\u003eT_Department;\r\n    T_Department--\u003eT_Professor;\r\n    T_Department--\u003eT_Student;\r\n```\r\n\r\nthe `DataExportOrder` file should have the following:\r\n```\r\nT_Campus\r\nT_Department\r\nT_Professor\r\nT_Student\r\n```\r\n* Loading data in this order assures that when the department data is loaded, the Campus\\_ID for each department will refer to an existing row in the campus table\r\n* Next, when the professor and student data is loaded, the Department\\_ID for each person will refer to an existing row in the department table\r\n\r\nUse `/Schema` or `/DefaultSchema` to define the default schema name to use when exporting data from tables\r\n* Entries in the `/DataTables` file will override this default schema\r\n\r\nUse `/ExistingDDL` or `/ExistingSchema` to define a text file that should be parsed to rename columns, based on data loaded from the `/ColumnMap` file\r\n* Will create a new text file with CREATE TABLE blocks that include the new column names\r\n  * Will skip columns with `\u003cskip\u003e`\r\n* Will skip tables (and views, procedures, etc.) that are defined in the `/DataTables` file but have `\u003cskip\u003e` in the TargetTableName column\r\n  * Does not rename tables\r\n\r\nUse `/ExportAllData` or `/ExportAllTables` to export data from every table in the database\r\n* Will skip tables (and views) that are defined in the `/DataTables` file but have `\u003cskip\u003e` in the TargetTableName column\r\n* Ignored if `/NoTableData` is true\r\n\r\nUse `/MaxRows` to define the maximum number of data rows to export\r\n* Defaults to 1000\r\n* Use 0 to export all rows\r\n* If you use `/ExportAllData` but do not specify `/MaxRows`, the program will auto set `/MaxRows` to 0\r\n\r\nUse `/NoTableData` or `/NoData` to prevent any table data from being exported\r\n* This parameter is useful when processing an existing DDL file with `/ExistingDDL`\r\n\r\nBy default, the table data load script will update the PostgreSQL system settings to set `log_min_duration_statement` to -1, which will disable logging statements that execute longer than a given threshold\r\n* If your system has `log_min_duration_statement` defined, and if the insert queries take longer than the threshold, the entire insert query (including all of the data values) will be written to the log file\r\n  * If you are importing a large amount of data, this could lead to very large PostgreSQL log file sizes\r\n* By using `/DisableStatementLogging:True` (the default) you avoid the possibility of long-running `INSERT INTO` queries bloating up the log files\r\n  * The database user must be a superuser to update the `log_min_duration_statement` system setting, since that setting affects all current and future connections in all databases on the server\r\n* After importing all of the data, the script will set `log_min_duration_statement` to 5000 (meaning to log statements that run longer than 5 seconds)\r\n  * This can be customized using `/MinLogDuration` (or `MinLogDurationAfterLoad=` in a parameter file)\r\n* Use `/DisableStatementLogging:False` to disabling adjusting the value of `log_min_duration_statement`\r\n\r\nUse `/MinLogDuration` to customize the value to set `log_min_duration_statement` to once all of the data has been imported\r\n* The default is `/MinLogDuration:5000`\r\n\r\nUse `/DeleteExtraRows` to create files with commands to delete extra rows in database tables (provided the table has one or more primary keys)\r\n* If `/ScriptLoad` is enabled (or the parameter file has `ScriptLoad=True`), the shell script will use these files to delete extra rows prior to importing new data\r\n* If `/DataExportOrder` was used to specify the export order for table data, the shell script will delete extra rows from tables in the reverse order from that defined in the `DataExportOrder` file\r\n  * The logic for this is that the purpose of the `DataExportOrder` file is to assure that \r\n\r\n* If a table has a single-column primary key, the delete queries will be of the form:\r\n```PLpgSQL\r\nDELETE FROM \"t_user_status\" target\r\nWHERE status BETWEEN 'Active' AND 'Obsolete' AND\r\n      NOT EXISTS ( SELECT S.status\r\n                   FROM \"t_user_status\" S\r\n                   WHERE target.status = S.status AND\r\n                         S.status in (\r\n'Active','Inactive','Obsolete'\r\n                         )\r\n                  );\r\n```\r\n\r\n* If a table has a multi-column based primary key, the delete queries will be of the form:\r\n```PLpgSQL\r\nDELETE FROM t_internal_std_composition target\r\nWHERE target.component_id BETWEEN 10 AND 72 AND\r\n      NOT EXISTS ( SELECT S.component_id\r\n                         ,S.mix_id\r\n                   FROM t_internal_std_composition S\r\n                   WHERE target.component_id = S.component_id AND\r\n                         target.mix_id = S.mix_id AND\r\n                         (\r\nS.component_id = 10 AND S.mix_id = 1 OR\r\nS.component_id = 10 AND S.mix_id = 3 OR\r\nS.component_id = 11 AND S.mix_id = 1 OR\r\nS.component_id = 11 AND S.mix_id = 3 OR\r\nS.component_id = 13 AND S.mix_id = 1 OR\r\nS.component_id = 13 AND S.mix_id = 3 OR\r\nS.component_id = 21 AND S.mix_id = 5 OR\r\nS.component_id = 22 AND S.mix_id = 5\r\n                         )\r\n                  );\r\n```\r\n\r\nUse `/ForceTruncate` to specify a table name (or comma separated list of names) that have a primary key, but you would rather truncate the table data instead of using either of the `DELETE FROM` queries shown above\r\n* This is useful for large tables where the `DELETE FROM` queries run very slowly\r\n* Names in this list can match either source table names or target table names\r\n* Ignored if `/DeleteExtraRows` is false\r\n\r\nUse `/DisableTriggers` (or `/IncludeDisableTriggerCommands`) to include trigger disable / enable commands in data export files\r\n* Ignored if `PgInsert` is true since `session_replication_role` is set to \"replica\" prior to inserting/deleting data\r\n\r\nUse `/ScriptLoad` or `/Script` to create a bash script file for loading exported table data into a PostgreSQL database\r\n\r\nUse `/ScriptUser` to define the username to use when calling `psql` in the bash script\r\n* If not defined, will use the username being used to run the DB Schema Export Tool\r\n\r\nUse `/ScriptDB` to define the target database name to use when calling `psql` in the bash script\r\n* The default is `/ScriptDB:dms`\r\n\r\nUse `/ScriptHost` to define the host name to use when calling `psql` in the bash script\r\n* The default is `/ScriptHost:localhost`\r\n\r\nUse `/ScriptPort` to define the port name to use when calling `psql` in the bash script\r\n* The default is `/ScriptPort:5432`\r\n* The port number will only be included in the bash script if it is not the default\r\n\r\nUse `/SnakeCase` to auto change column names from Upper\\_Case and UpperCase to lower_case when exporting data from tables\r\n* Also used for table names when exporting data from tables\r\n* Entries in the `/DataTables` and `/ColumnMap` files will override auto-generated snake_case names\r\n\r\nUse `/PgDump` or `/PgDumpData` to specify that exported data should use `COPY` commands instead of `INSERT INTO` statements\r\n* With SQL Server databases, table data will be exported using pg_dump compatible COPY commands when `/PgDump` is used\r\n* With PostgreSQL data, table data will be exported using the pg_dump application\r\n* With SQL Server data and PostgreSQL data, if `/PgDump` is not provided, data is exported with `INSERT INTO` statements\r\n* With SQL Server data, if `/PgDump` is provided, but the `/DataTables` file has `true` in the `PgInsert` column, `INSERT INTO` statements will be used for that table\r\n\r\nUse `/KeepPgDumpFile` to not delete the `_AllObjects_.sql` created for each database\r\n* By default, this is false, meaning the `_AllObjects_.sql` file will be deleted (since it is no longer needed because a separate .sql file has been created for each object)\r\n** If any unhandled scripting commands are encountered, the `_AllObjects_.sql` file will not be deleted, even if KeepPgDumpFile is false\r\n* In addition, when this is true, store the original PgDump table data files in directory `Replaced_PgDump_Files`\r\n\r\nThe `/PgInsert` applies when exporting data from SQL Server database tables\r\n* While reading the TableDataToExport.txt file, default the PgInsert column to true when `/PgInsert` is provided, meaning table data will be exported via INSERT INTO statements, as mentioned above\r\n* Ignored for PostgreSQL data\r\n\r\nUse `PgInsertChunkSize` to specify the number of values to insert at a time when PgInsert is true for a table\r\n* Only applicable when exporting data from SQL Server\r\n\r\nUse `/ServerInfo` to export server settings, logins, and SQL Server Agent jobs\r\n\r\nUse `/NoSchema` to skip exporting schema (tables, views, functions, etc.)\r\n\r\nUse `/Sync` to copy new/changed files from the output directory to an alternative directory\r\n* This is advantageous to prevent file timestamps from getting updated every time the schema is exported\r\n\r\nUse `/Git` to auto-update any new or changed files using Git\r\n\r\nUse `/Svn` to auto-update any new or changed files using Subversion\r\n\r\nUse `/Hg`  to auto-update any new or changed files using Mercurial\r\n\r\nUse `/Commit` to commit any updates to the repository\r\n\r\nUse `/L` to log messages to a file\r\n\r\nUse `/LogFile` to specify the base name for the log file\r\n* Log files will be named using the base name, followed by the current date\r\n\r\nUse `/LogDir` or `/LogDirectory` to specify the directory to save the log file in\r\n* By default, the log file is created in the current working directory\r\n\r\nUse `/Preview` to count the number of database objects that would be exported\r\n\r\nUse `/Stats` to show (but not log) export stats\r\n\r\nUse `/Trace` to show additional debug messages at the console\r\n\r\nThe processing options can be specified in a parameter file using `/ParamFile:Options.conf` or `/Conf:Options.conf` or `/P:Options.conf`\r\n* Define options using the format `ArgumentName=Value`\r\n* Lines starting with `#` or `;` will be treated as comments\r\n* Additional arguments on the command line can supplement or override the arguments in the parameter file\r\n\r\nUse `/CreateParamFile` to create an example parameter file\r\n* By default, the example parameter file content is shown at the console\r\n* To create a file named Options.conf, use `/CreateParamFile:Options.conf`\r\n\r\n## Software Dependencies\r\n\r\nThis program leverages the SQL Server Management Objects (SMO) Framework\r\n* All of the required DLLs should be included in the DBSchemaExportTool .zip file\r\n\r\nIn order to use the `/Git,` `/Svn,` or `/Hg` switches, you need the following software installed\r\nand the executables present at a specific location:\r\n\r\nGit\r\n* `C:\\Program Files\\Git\\bin\\git.exe`\r\n* Installed with 64-bit Git for Windows, available at https://git-scm.com/download/win\r\n\r\nSubversion:\r\n* `C:\\Program Files\\TortoiseSVN\\bin\\svn.exe`\r\n* Installed with 64-bit Tortoise SVN, available at https://tortoisesvn.net/downloads.html\r\n\r\nMercurial\r\n* `C:\\Program Files\\TortoiseHg\\hg.exe`\r\n* Installed with 64-bit Tortoise Hg,  available at https://tortoisehg.bitbucket.io/download/index.html\r\n\r\n### PostgreSQL\r\n\r\nSchema export from PostgreSQL databases utilizes the pg_dump utility\r\n* `pg_dump.exe` is available as part of the PostgreSQL for Windows installer from the EDB website\r\n  * https://www.enterprisedb.com/downloads/postgres-postgresql-downloads\r\n* Run the installer\r\n  * De-select installing PostgreSQL Server\r\n* Copy `pg_dump.exe` plus several DLLs from `C:\\Program Files\\PostgreSQL\\16\\bin` to the directory with the DB_Schema_Export_Tool executable\r\n  * See batch file `Copy_pg_dump_files.bat`\r\n\r\nFile `pgpass.conf` at `%APPDATA%\\postgresql` can be used to store the password for the PostgreSQL user\r\n* On Linux, the file is stored at `~/.pgpass`\r\n\r\n```\r\nmkdir %APPDATA%\\postgresql\r\necho prismweb3:5432:dms:dmsreader:dmspasswordhere \u003e %APPDATA%\\postgresql\\pgpass.conf\r\n```\r\n\r\nExample call to pg_dump:\r\n```\r\npg_dump.exe -h prismweb3 -p 5432 -U dmsreader -d dms --schema-only --format=p --file=_AllObjects_.sql\r\n```\r\n\r\nNote that on Windows the .sql file created by `pg_dump.exe` includes extra carriage returns, resulting in `CR CR LF` instead of `CR LF`\r\n* DB_Schema_Export_Tool.exe removes the extra carriage returns while parsing the SQL dump file\r\n\r\n## Contacts\r\n\r\nWritten by Matthew Monroe for the Department of Energy (PNNL, Richland, WA) \\\r\nE-mail: matthew.monroe@pnnl.gov or proteomics@pnnl.gov\\\r\nWebsite: https://github.com/PNNL-Comp-Mass-Spec/ or https://www.pnnl.gov/integrative-omics\r\nSource code: https://github.com/PNNL-Comp-Mass-Spec/DB-Schema-Export-Tool\r\n\r\n## License\r\n\r\nThe DB Schema Export Tool is licensed under the 2-Clause BSD License;\r\nyou may not use this program except in compliance with the License.  You may obtain\r\na copy of the License at https://opensource.org/licenses/BSD-2-Clause\r\n\r\nCopyright 2019 Battelle Memorial Institute\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPNNL-Comp-Mass-Spec%2FDB-Schema-Export-Tool/lists"}