|
1 | | -# SQLWrapper |
2 | | -A high performance SQL Wrapper and syntax checking supporting MySQL, MariaDB... SQLWrapper generate call code from SQL file and check SQL syntax before compile task. The call automatically created and check syntax identify database changes. |
| 1 | +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. |
3 | 2 |
|
4 | | -SQL Wrapper is not a ORM: it generate code form SQL request. It have better performance than linq or EntityFramework and there are not SQL limitation. |
| 3 | +It'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. |
5 | 4 |
|
6 | | -SQL Wrapper get database structure to check SQL syntax and generate a XML with all returned columns of SQL request. From this XML, you can apply our XLST (or the XLST provided) to generate the code. |
| 5 | +One 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. |
7 | 6 |
|
8 | | -Thus, SQL Wrapper can generate SQL call code from any language like C#, Java, Python, Javascript, VB .NET, ADO .NET ... |
| 7 | +Overall, SQLWrapper is a handy tool for making SQL code easier to work with, saving time, and helping you write better code. |
9 | 8 |
|
10 | | -# nuget installation |
| 9 | +## Getting started with package NuGet Daikoz.SQLWrapper |
11 | 10 |
|
12 | | -Use nuget to install package [Daikoz.SQLWrapper package](https://www.nuget.org/packages/Daikoz.SQLWrapper/) |
| 11 | +The .NET package NuGet [Daikoz.SQLWrapper](https://www.nuget.org/packages/Daikoz.SQLWrapper) integrate SQLWrapper in build process of our .NET project. |
13 | 12 |
|
14 | | -# SQLWrapper Extention |
15 | | -The SQLWrapper extention is a pugin to add to our projet csproj. The SQL file is automatically generate. |
| 13 | +1. Create your .NET project |
| 14 | +2. Add package NuGet Daikoz.SQLWrapper. |
16 | 15 |
|
17 | | -# Architecture |
18 | | - |
19 | | -1. **Read database structure** |
20 | | - |
21 | | - SQL Wrapper ----> read database ----> extract database structure (table, columns, ...) |
22 | | - |
23 | | -2. **Extract SQL result from SQL file** |
| 16 | +.NET CLI: |
| 17 | +``` |
| 18 | +dotnet add package Daikoz.SQLWrapper |
| 19 | +``` |
| 20 | +or use [Manage NuGet Packages...] in Visual Studio |
24 | 21 |
|
25 | | - SQL File + DB Structure ----> SQLWrapper ----> XML File |
26 | | - |
27 | | -3. **Generate our code** |
| 22 | +3. The first build create on your project root, the configuration file **sqlwrapper.conf** |
28 | 23 |
|
29 | | - XSLT (default or provide one) ----> SQL Wrapper ----> C# code wrapper |
30 | | - |
31 | | - |
32 | | -# Configuration |
| 24 | +``` json |
| 25 | +{ |
| 26 | + "Verbose": false, |
| 27 | + "Database": [ |
| 28 | + { |
| 29 | + "Name": "Name of this database. Should be contain only characters: a-z A-Z 0-9 _ -", |
| 30 | + "ConnectionString": ".NET connection string to connect to database. If empty, use FilePath to get cached database previously generated.", |
| 31 | + "FilePath": "File path of cached database. If empty, store it in obj of project" |
| 32 | + } |
| 33 | + ], |
| 34 | + "Helper": [ |
| 35 | + { |
| 36 | + "Database": "Name of database defined in Database section", |
| 37 | + "Namespace": "Namespace in generated source. If empty, take the default namespace of project", |
| 38 | + "XLST": "Provide your own XLST to generate a helper. If empty, use default XLST provided by SQLWrapper", |
| 39 | + "OutputFilePath": "File path of helper" |
| 40 | + } |
| 41 | + ], |
| 42 | + "Wrapper": [ |
| 43 | + { |
| 44 | + "Database": "Name of database defined in Database section", |
| 45 | + "Namespace": "Namespace in generated source. If empty, take the default namespace of project", |
| 46 | + "XLST": "Provide your own XLST to generate the wrapper. If empty, use default XLST provided by SQLWrapper", |
| 47 | + "Path": "Absolute or relative path where to search sql file pattern. If empty, use path of project", |
| 48 | + "FilePattern": "SQL file to wrap. If empty, use \"*.sql\"" |
| 49 | + } |
| 50 | + ] |
| 51 | +} |
| 52 | +``` |
33 | 53 |
|
34 | | -if no configuration not found in root of csproj, one is created: |
| 54 | +To start, follow a minimal configuration file. Modify HOSTNAME, USERID, PASSWORD and DATABASENAME |
35 | 55 |
|
36 | | -```json |
37 | | -[ |
38 | | - { |
39 | | - "RelativePath": [ "" ], |
40 | | - "FilePattern": "*.sql", |
41 | | - "Namespace": "Daikoz", |
42 | | - "ConnectionStrings": [ |
43 | | - "server=mysqlserver;user id=user1;password=pwd;database=DB1;", |
44 | | - "server=mysqlserver;user id=user2;password=pwd;database=DB2;" |
| 56 | +``` json |
| 57 | +{ |
| 58 | + "Database": [ |
| 59 | + { |
| 60 | + "Name": "MyDatabase", |
| 61 | + "ConnectionString": "server=HOSTNAME;user id=USERID;password='PASSWORD';database=DATABASENAME" |
| 62 | + } |
| 63 | + ], |
| 64 | + "Helper": [ |
| 65 | + { |
| 66 | + "Database": "MyDatabase", |
| 67 | + "OutputFilePath": "MyDataseHelper.cs" |
| 68 | + } |
| 69 | + ], |
| 70 | + "Wrapper": [ |
| 71 | + { |
| 72 | + "Database": "MyDatabase" |
| 73 | + } |
45 | 74 | ] |
46 | | - } |
47 | | -] |
| 75 | +} |
48 | 76 | ``` |
49 | 77 |
|
50 | | -* **RelativePath**: array of string - relative path where found SQL file |
51 | | -* **FilePattern**: string - sql file |
52 | | -* **Namespace**: string - namespace of generated class |
53 | | -* **ConnectionString**: array of string - list of connection string |
| 78 | +4. Add your database query in files .sql in your project |
| 79 | +5. Build you project |
| 80 | +* Your database structure is cached in obj |
| 81 | +* A database helper if generate in file MyDataseHelper.cs |
| 82 | +* For each *.sql, a wrapper is generated |
| 83 | + |
| 84 | +## Getting started with command line SQLWrapper |
54 | 85 |
|
| 86 | +## Links |
| 87 | +* [Official web](https://www.sqlwrapper.com) |
| 88 | +* [Package .NET](https://www.nuget.org/packages/Daikoz.SQLWrapper/) |
| 89 | +* [Documentation](https://github.com/daikoz/SQLWrapper/wiki) |
| 90 | +* [Issues/Bugs](https://github.com/daikoz/SQLWrapper/issues) |
| 91 | +* [Videos](https://www.youtube.com/@SQLWrapper) |
| 92 | +* [Reddit](https://www.reddit.com/r/sqlwrapper/) |
| 93 | +* [Facebook](https://www.facebook.com/sqlwrapper/) |
| 94 | +* [Twitter](https://twitter.com/sqlwrapper) |
0 commit comments