{"id":30369393,"url":"https://github.com/dsacms/npd_durc_is_crud","last_synced_at":"2025-08-20T02:15:34.564Z","repository":{"id":307709181,"uuid":"1024484228","full_name":"DSACMS/npd_durc_is_crud","owner":"DSACMS","description":"Python version of DURC","archived":false,"fork":false,"pushed_at":"2025-08-01T17:08:05.000Z","size":139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-01T19:26:28.567Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"cc0-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DSACMS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2025-07-22T19:16:16.000Z","updated_at":"2025-08-01T17:08:07.000Z","dependencies_parsed_at":"2025-08-01T19:36:36.188Z","dependency_job_id":null,"html_url":"https://github.com/DSACMS/npd_durc_is_crud","commit_stats":null,"previous_names":["dsacms/npd_durc_is_crud"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/DSACMS/npd_durc_is_crud","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSACMS%2Fnpd_durc_is_crud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSACMS%2Fnpd_durc_is_crud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSACMS%2Fnpd_durc_is_crud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSACMS%2Fnpd_durc_is_crud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DSACMS","download_url":"https://codeload.github.com/DSACMS/npd_durc_is_crud/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DSACMS%2Fnpd_durc_is_crud/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271252993,"owners_count":24726918,"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","status":"online","status_checked_at":"2025-08-20T02:00:09.606Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-08-20T02:15:32.301Z","updated_at":"2025-08-20T02:15:34.556Z","avatar_url":"https://github.com/DSACMS.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DURC Is CRUD\n\nDURC (Database to CRUD) is a Python package that simplifies the process of generating CRUD (Create, Read, Update, Delete) operations from database schemas. It automatically extracts relational models from your database and generates the necessary code artifacts.\n\n## Features\n\n- **Database Schema Extraction**: Automatically extract database schema information including tables, columns, primary keys, foreign keys, and relationships.\n- **Relationship Detection**: Automatically detect relationships between tables based on foreign keys and naming conventions.\n- **Code Generation**: Generate code artifacts based on the extracted relational model (currently a placeholder, with full implementation coming soon).\n- **PostgreSQL Support**: Currently optimized for PostgreSQL databases, with plans to support other database systems in the future.\n- **Django Integration**: Seamlessly integrates with Django projects through management commands.\n\n## Installation\n\n### For End Users\n\n1. After installing and initially setting up your Django instance, use pip to install durc with: \n\n```bash\n# Basic installation (includes testing capabilities)\npip install durc-is-crud\n\n# Installation with development dependencies (for contributors)\npip install durc-is-crud[dev]\n```\n\n2. Add `durc_is_crud` to your `INSTALLED_APPS` in your Django settings:\n\n   ```python\n   INSTALLED_APPS = [\n       # ...\n       'durc_is_crud',\n       # ...\n   ]\n   ```\n\n### For Local Development\n\nIf you want to contribute to DURC or set up a local development environment, follow these steps:\n\n#### Prerequisites\n\n- Python 3.9+ (required by pyproject.toml)\n- Django 3.0+\n- PostgreSQL (for database operations)\n- Git\n\n#### Step 1: Clone and Set Up Virtual Environment\n\n```bash\n# Clone the repository\ngit clone https://github.com/ftrotter/durc_is_crud.git\ncd durc_is_crud\n\n# Create and activate virtual environment\npython -m venv venv\nsource venv/bin/activate  # On Windows: venv\\Scripts\\activate\n\n# Or use the provided script\nsource source_me_to_get_venv.sh\n```\n\n#### Step 2: Install Dependencies\n\n```bash\n# Install the package in development mode with all dependencies\npip install -e .\n\n# Or install with development dependencies\npip install -e .[dev]\n\n# Or use the build script\n./scripts/build_and_install.sh\n```\n\n#### Step 3: Verify Installation\n\n```bash\n# Test that all commands are available\npython -c \"import durc_is_crud; print('Package imported successfully')\"\n\n# Test standalone CLI command\ndurc-mine-fkeys --help\n\n# If you have a Django project, test Django commands\npython manage.py durc_mine --help\npython manage.py durc_compile --help\npython manage.py durc_diagram --help\npython manage.py durc_mine_fkeys --help\npython manage.py durc_test --help\n```\n\n## Usage\n\n### Django Management Commands\n\nOnce installed, DURC provides several Django management commands:\n\n1. **Extract the relational model from your database:**\n\n   ```bash\n   python manage.py durc_mine --include mydb.public\n   \n   # Multiple patterns\n   python manage.py durc_mine --include mydb.public mydb.private\n   \n   # Custom output file\n   python manage.py durc_mine --include mydb.public --output_json_file custom/model.json\n   ```\n\n2. **Compile the relational model into code artifacts:**\n\n   ```bash\n   python manage.py durc_compile\n   ```\n\n3. **Generate database diagrams from SQL files:**\n\n   ```bash\n   python manage.py durc_diagram --sql_files schema.sql --output_md_file diagram.md\n   \n   # Multiple SQL files\n   python manage.py durc_diagram --sql_files file1.sql file2.sql --output_md_file combined_diagram.md\n   ```\n\n4. **Generate foreign key statements:**\n\n   ```bash\n   python manage.py durc_mine_fkeys --include mydb.public\n   ```\n\n5. **Run tests for the DURC package:**\n\n   ```bash\n   # Run all tests (both standalone and Django-dependent)\n   python manage.py durc_test\n\n   # Run only standalone tests that don't require Django\n   python manage.py durc_test --standalone-only\n\n   # Run only tests that require Django\n   python manage.py durc_test --django-only\n   \n   # Verbose output\n   python manage.py durc_test -v 2\n   ```\n\n### Standalone CLI Commands\n\nDURC also provides standalone CLI commands that don't require Django:\n\n1. **Generate foreign key statements from existing relational model:**\n\n   ```bash\n   # Use default paths\n   durc-mine-fkeys\n   \n   # Custom input/output files\n   durc-mine-fkeys --input_json_file custom/model.json --output_sql_file custom/fkeys.sql\n   ```\n\n### Development Workflow\n\nFor developers working on DURC:\n\n1. **Set up development environment** (see installation steps above)\n\n2. **Run tests before making changes:**\n   ```bash\n   python manage.py durc_test\n   # Or use pytest directly\n   pytest tests/\n   ```\n\n3. **Make your changes**\n\n4. **Run tests again to ensure nothing broke:**\n   ```bash\n   python manage.py durc_test -v 2\n   ```\n\n5. **Test with a real database:**\n   ```bash\n   # Mine a database schema\n   python manage.py durc_mine --include your_db.your_schema\n   \n   # Generate foreign keys\n   python manage.py durc_mine_fkeys --include your_db.your_schema\n   \n   # Create diagrams\n   python manage.py durc_diagram --sql_files your_schema.sql --output_md_file test_diagram.md\n   ```\n\n6. **Build and test the package:**\n   ```bash\n   ./scripts/build_and_install.sh\n   ```\n\n### File Structure\n\nAfter running DURC commands, you'll typically see these files created:\n\n```\ndurc_config/\n├── DURC_relational_model.json    # Generated by durc_mine\n├── foreign_keys.sql              # Generated by durc_mine_fkeys\n└── other_output_files...\n```\n\n## Troubleshooting\n\n### Common Issues and Solutions\n\n#### 1. Import Errors\n\n**Problem:** `ModuleNotFoundError: No module named 'durc_is_crud'`\n\n**Solution:**\n```bash\n# Make sure you're in the right directory and virtual environment is activated\nsource venv/bin/activate  # or source source_me_to_get_venv.sh\n\n# Reinstall in development mode\npip install -e .\n```\n\n#### 2. Django Commands Not Found\n\n**Problem:** `Unknown command: 'durc_mine'`\n\n**Solution:**\n```bash\n# Ensure durc_is_crud is in your INSTALLED_APPS\n# Check your Django settings.py file\n\n# Verify Django can find the commands\npython manage.py help | grep durc\n```\n\n#### 3. Database Connection Issues\n\n**Problem:** Database connection errors when running `durc_mine`\n\n**Solution:**\n```bash\n# Ensure your Django database settings are correct\n# Test Django database connection first\npython manage.py dbshell\n\n# Check your database credentials and permissions\n```\n\n#### 4. Permission Issues with Scripts\n\n**Problem:** `Permission denied` when running shell scripts\n\n**Solution:**\n```bash\n# Make scripts executable\nchmod +x scripts/build_and_install.sh\nchmod +x source_me_to_get_venv.sh\n\n# Then run them\n./scripts/build_and_install.sh\n```\n\n#### 5. Virtual Environment Issues\n\n**Problem:** Commands not working or wrong Python version\n\n**Solution:**\n```bash\n# Recreate virtual environment\nrm -rf venv\npython3.9 -m venv venv  # Use Python 3.9+ as required\nsource venv/bin/activate\n\n# Verify Python version\npython --version  # Should be 3.9+\n\n# Reinstall dependencies\npip install -e .[dev]\n```\n\n#### 6. Test Failures\n\n**Problem:** Tests failing during development\n\n**Solution:**\n```bash\n# Run tests with verbose output to see details\npython manage.py durc_test -v 2\n\n# Run specific test categories\npython manage.py durc_test --standalone-only\npython manage.py durc_test --django-only\n\n# Use pytest directly for more control\npytest tests/ -v\npytest tests/test_utils/ -v\n```\n\n#### 7. CLI Command Not Found\n\n**Problem:** `durc-mine-fkeys: command not found`\n\n**Solution:**\n```bash\n# Ensure package is installed correctly\npip install -e .\n\n# Check if command is in PATH\nwhich durc-mine-fkeys\n\n# If not found, try running directly\npython -m durc_is_crud.cli.durc_mine_fkeys --help\n```\n\n### Getting Help\n\nIf you encounter issues not covered here:\n\n1. Check the [tests/](tests/) directory for examples of how commands should work\n2. Look at the [AI_Instructions/](AI_Instructions/) directory for detailed documentation\n3. Run commands with verbose output (`-v 2`) to get more debugging information\n4. Check that all prerequisites are installed and up to date\n\nFor more detailed usage instructions, see the [Usage Guide](docs/usage.md).\n\n## Documentation\n\n- [Installation Guide](docs/installation.md)\n- [Usage Guide](docs/usage.md)\n- [Testing Guide](tests/README.md)\n\n## Requirements\n\n- Python 3.9+ (for development)\n- Python 3.6+ (for end users, but 3.9+ recommended)\n- Django 3.0+\n- PostgreSQL (for database operations)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## Policies\n\n### Open Source Policy\n\nWe adhere to the [CMS Open Source Policy](https://github.com/CMSGov/cms-open-source-policy). If you have any questions, just [shoot us an email](mailto:opensource@cms.hhs.gov).\n\n### Security and Responsible Disclosure Policy\n\n_Submit a vulnerability:_ Vulnerability reports can be submitted through [Bugcrowd](https://bugcrowd.com/cms-vdp). Reports may be submitted anonymously. If you share contact information, we will acknowledge receipt of your report within 3 business days.\n\n### Software Bill of Materials (SBOM)\n\nA Software Bill of Materials (SBOM) is a formal record containing the details and supply chain relationships of various components used in building software.\n\nIn the spirit of [Executive Order 14028 - Improving the Nation's Cyber Security](https://www.gsa.gov/technology/it-contract-vehicles-and-purchasing-programs/information-technology-category/it-security/executive-order-14028), a SBOM for this repository is provided here: https://github.com/{{ cookiecutter.project_org }}/{{ cookiecutter.project_repo_name }}/network/dependencies.\n\nFor more information and resources about SBOMs, visit: https://www.cisa.gov/sbom.\n\n## Public domain\n\nThis project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/) as indicated in [LICENSE](LICENSE).\n\nAll contributions to this project will be released under the CC0 dedication. By submitting a pull request or issue, you are agreeing to comply with this waiver of copyright interest.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsacms%2Fnpd_durc_is_crud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdsacms%2Fnpd_durc_is_crud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdsacms%2Fnpd_durc_is_crud/lists"}