{"id":19993778,"url":"https://github.com/daikoz/SQLWrapper","last_synced_at":"2025-05-04T12:32:42.295Z","repository":{"id":37922504,"uuid":"176819976","full_name":"daikoz/SQLWrapper","owner":"daikoz","description":"SQLWrapper is a tool that simplifies creating code wrappers for SQL queries. It supports various SQL databases, checks syntax and performance, and generates code directly from queries and database structures. SQLWrapper saves time and helps to maintain and write better wrapper SQL code.","archived":false,"fork":false,"pushed_at":"2025-04-20T08:50:03.000Z","size":125068,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-20T09:47:24.341Z","etag":null,"topics":["builder","dapper","database","linq","mariadb","mssql","mysql","orm","pgsql","postgres","postgresql","query","query-builder","server","sql","sqlite","sqlwrapper","wrapper"],"latest_commit_sha":null,"homepage":"https://www.sqlwrapper.com","language":"XSLT","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daikoz.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"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":"2019-03-20T21:29:35.000Z","updated_at":"2025-04-20T08:45:57.000Z","dependencies_parsed_at":"2024-04-07T22:22:49.053Z","dependency_job_id":"206d7121-6c4c-41c3-ad3b-97f0d4db9744","html_url":"https://github.com/daikoz/SQLWrapper","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikoz%2FSQLWrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikoz%2FSQLWrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikoz%2FSQLWrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daikoz%2FSQLWrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daikoz","download_url":"https://codeload.github.com/daikoz/SQLWrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252335184,"owners_count":21731536,"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":["builder","dapper","database","linq","mariadb","mssql","mysql","orm","pgsql","postgres","postgresql","query","query-builder","server","sql","sqlite","sqlwrapper","wrapper"],"created_at":"2024-11-13T04:52:59.015Z","updated_at":"2025-05-04T12:32:37.287Z","avatar_url":"https://github.com/daikoz.png","language":"XSLT","readme":"SQLWrapper makes it easier to create code wrappers for SQL queries. It's a powerful tool that helps speed up development by reducing the need for manual coding. It works with databases various SQL database (MySQL, MariaDB, ...), checking the syntax and performance of SQL queries before you execute them.\n\nIt's important to note that SQLWrapper isn't like other tools that map objects to database tables (ORMs). Instead, it directly generates code from your SQL queries and database structure, which performs better than tools like LINQ, EntityFramework, dapper, ... and doesn't have the same limitations.\n\nOne feature is that it can look at your database's structure to check if your SQL queries are correct, and it can create an XML file listing all the data your queries need and return. Then, you can use XSLT templates to turn that XML into code in languages like C#, and more.\n\nOverall, SQLWrapper is a handy tool for making SQL code easier to work with, saving time, and helping you write better code.\n\n## Links\n* [Change log](https://github.com/daikoz/SQLWrapper/blob/master/CHANGELOG.md)\n* [Official website](https://www.sqlwrapper.com)\n* [Package .NET](https://www.nuget.org/packages/Daikoz.SQLWrapper/)\n* [Documentation](https://github.com/daikoz/SQLWrapper/wiki)\n* [Issues/Bugs](https://github.com/daikoz/SQLWrapper/issues)\n* [Videos](https://www.youtube.com/@SQLWrapper)\n* [Facebook](https://www.facebook.com/sqlwrapper/)\n* [Twitter](https://twitter.com/sqlwrapper)\n\n## Features\n\n| Database | language | function wrapper | stored procedure wrapper | SQL query wrapper | check SQL query syntax |\n| --- | :---: | :---: | :---: | :---: | :---: |\n| **mysql** | C# .Net\u003cbr/\u003eVisual Basic .Net | ✓ | ✓ | ✓ | ✓ |\n| **mariadb** | C# .Net\u003cbr/\u003eVisual Basic .Net | ✓ | ✓ | ✓ | ✓ |\n\n## Getting started with package NuGet Daikoz.SQLWrapper\n\n**Video of demonstration:**\n\n[![Watch the video](https://raw.githubusercontent.com/daikoz/SQLWrapper/master/img/video.jpg)](https://www.youtube.com/watch?v=xEeWnESZki0)\n\nThe .NET package NuGet [Daikoz.SQLWrapper](https://www.nuget.org/packages/Daikoz.SQLWrapper) integrate SQLWrapper in build process of our .NET project.\n\n1. Create your .NET project\n2. Add package NuGet Daikoz.SQLWrapper.\n\n.NET CLI:\n```\ndotnet add package Daikoz.SQLWrapper\n```\nor use [Manage NuGet Packages...] in Visual Studio\n\n3. The first build create on your project root, the configuration file **sqlwrapper.conf**\n\n``` json\n{\n    \"Verbose\": false,\n    \"Schema\": [\n        {\n            \"Name\": \"Name of this database. Should be contain only characters: a-z A-Z 0-9 _ -\",\n            \"ConnectionString\": \".NET connection string to connect to database. If empty, use FilePath to get cached database previously generated.\",\n            \"FilePath\": \"File path of cached database schema. If empty, store it in obj of project\",\n            \"CustomType\": [\n                \"SQLTable.SQLType=LanguageType\",\n                \"SQLColumnName=LanguageType\",\n                \"@SQLVariable=LanguageType\"\n            ]\n        }\n    ],\n    \"Wrapper\": {\n        \"Database\": [\n            {\n                \"Schema\": \"Name of database schema defined in Schema section\",\n                \"Namespace\": \"Namespace in generated source. If empty, take the default namespace of project\",\n                \"XLST\": \"Provide your own XLST to generate a helper. If empty, use default XLST provided by SQLWrapper\",\n                \"OutputFilePath\": \"File path of schema\"\n            }\n        ],\n        \"SQL\": [\n            {\n                \"Database\": \"Name of database defined in Schema section\",\n                \"Namespace\": \"Namespace in generated source. If empty, take the default namespace of project\",\n                \"XLST\": \"Provide your own XLST to generate the wrapper. If empty, use default XLST provided by SQLWrapper\",\n                \"Path\": \"Absolute or relative path where to search sql file pattern. If empty, use path of project\",\n                \"FilePattern\": \"SQL file to wrap. If empty, use \\\"*.sql\\\"\"\n            }\n        ]\n    }\n}\n```\n\nTo start, follow a minimal configuration file. Modify HOSTNAME, USERID, PASSWORD and DATABASENAME\n\n``` json\n{\n    \"Schema\": [\n        {\n            \"Name\": \"MyDatabase\",\n            \"ConnectionString\": \"server=HOSTNAME;user id=USERID;password='PASSWORD';database=DATABASENAME\"\n        }\n    ],\n    \"Wrapper\": {\n        \"Database\": [\n            {\n                \"Schema\": \"MyDatabase\",\n                \"OutputFilePath\": \"MyDatabaseHelper.cs\"\n            }\n        ],\n        \"SQL\": [\n            {\n                \"Schema\": \"MyDatabase\"\n            }\n        ]\n    }\n}\n```\n\n4. Add your database query in files .sql in your project\n5. Build you project\n* Your database schema is cached in obj\n* A database helper if generate in file MyDataseHelper.cs\n* For each *.sql, a wrapper is generated\n\n\n## Getting started with command line SQLWrapper\n\nSQLWrapper can be use in console.\n\n### Cache Schema \n\nFirst, extract and cache database structure in XML File:\n\n``` dos\n\u003eSQLWrapper.exe help schema\nSQL Wrapper Generator 2.1\nCopyright (C) DAIKOZ. All rights reserved.\nUSAGE:\nExtract and cache database schema in XML file:\n  SQLWrapper schema --connectionstring \"server=servernamedb;user id=userid;password='password';database=db1\"\n  --outputfile sqlwrapper-cachedb.xml --type mariadb --verbose\n\n  -t, --type                Required. Type of database: mysql, mariadb.\n\n  -c, --connectionstring    Required. List of .net database connection string\n                            (https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/connection-string-syntax).\n\n  -o, --outputfile          Output XML file (default: stdout).\n\n  -v, --verbose             Set output to verbose messages.\n\n  --help                    Display this help screen.\n\n  --version                 Display version information.\n```\n\n**Example:**\n\n``` dos\nSQLWrapper schema --connectionstring \"server=servernamedb;user id=userid;password='password';database=db1\" --outputfile sqlwrapper-cachedb.xml --type mariadb --verbose\n```\n\nThis command connect to **database** of **type** with connection information **connectionstring**. It generate a schema in XML. The output is written in **outputfile**.\n\n### SQL Wrapper\n\nGenerate the wrapper source code from SQL queries:\n\n``` dos\n\u003eSQLWrapper.exe help wrapper-sql\nSQL Wrapper Generator 2.1\nCopyright (C) DAIKOZ. All rights reserved.\nUSAGE:\nGenerate code from sql request:\n  SQLWrapper wrapper-sql --inputfiles request1.mysql request2.mysql --outputfile mysqlrequest.cs --params\n  namespace=DAIKOZ classname=SQLWrapper --schema sqlwrapper-cachedb.xml --xslt Template\\sql-cshapr-ado.xslt\n\n  -s, --schema         Required. XML file of cache database schema to load. Generate it before with database command\n\n  -i, --inputfiles     Required. SQL files. Relative or full path. wildcard * is supported for filename.\n\n  -o, --outputfile     Output file\n\n  -p, --params         XLST Parameters\n\n  -t, --customtypes    Force custom type for database field (table.col=MyEmu\n\n  -x, --xslt           XSLT file path to transform XML output.\n\n  -v, --verbose        Set output to verbose messages.\n\n  --help               Display this help screen.\n\n  --version            Display version information.\n```\n\n**Example:**\n\n``` dos\nSQLWrapper wrapper-sql --schema sqlwrapper-cachedb.xml --inputfiles request1.mysql request2.mysql --outputfile mysqlrequest.cs --params namespace=DAIKOZ classname=SQLWrapper --xslt template\\sql-cshapr-ado.xslt\n```\n\nThis command create a **SQL wrapper** from **database** for 2 queries defined in **inputfiles**. It use the **XSLT** file to generate the **outputfile**. **params** give parameters defined in **XLST** file (here the namespace).\n\n### Database Wrapper Helper\n\nGenerate a source code helper to help the access to database. For example: the length of all text columns, functions and stored procedures\n\n``` dos\n\u003eSQLWrapper.exe help wrapper-database\nSQL Wrapper Generator 2.0.1.1+fe5be6893053615a1ac4a351bb4da3c110a6355d\nCopyright (C) DAIKOZ. All rights reserved.\nUSAGE:\nGenerate code helper to access database:\n  SQLWrapper wrapper-database --outputfile helper.cs --schema sqlwrapper-cachedb.xml --xslt Template\\database-csharp-ado.xslt\n\n  -s, --schema         Required. XML file of cache database schema to load. Generate it before with database command\n\n  -o, --outputfile     Output file\n\n  -p, --params         XLST Parameters\n\n  -t, --customtypes    Force custom type for database field (table.col=MyEmu\n\n  -x, --xslt           XSLT file path to transform XML output.\n\n  -v, --verbose        Set output to verbose messages.\n\n  --help               Display this help screen.\n\n  --version            Display version information.\n```\n\n**Example:**\n\n``` dos\nSQLWrapper wrapper-database --schema sqlwrapper-cachedb.xml --outputfile MyDatabaseHelper.cs --xslt template\\database-csharp-ado.xslt\n```\n\nThis command create a **helper** for **database**. It use **XLST** file to generate the **outputfile**.\n\n\n## Template XLST\n\nIn template section, you can found several XLST files to generate SQL and database wrappers/helpers in several programming language.\nYou can create or modify your own and use it with **--xslt** parameter.\nDAIKOZ can help you to create your own XLST. Contact us.\n\n### Template available\n\nGenerate a **database helper** from XML Schema in:\n- C# .Net: **database-csharp-ado.xslt**\n- Visual Basic .Net: **database-vb-ado.xslt**\n\nGenerate a **SQL query wrapper** from XML schema and SQL query in:\n- C# .Net: **sql-cshapr-ado.xslt**\n- Visual Basic: **sql-vb-ado.xslt**\n","funding_links":[],"categories":["XSLT","Source Generators"],"sub_categories":["Database / ORM"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaikoz%2FSQLWrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaikoz%2FSQLWrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaikoz%2FSQLWrapper/lists"}