https://github.com/senselogic/alchemy
Database converter.
https://github.com/senselogic/alchemy
Last synced: 4 months ago
JSON representation
Database converter.
- Host: GitHub
- URL: https://github.com/senselogic/alchemy
- Owner: SenseLogic
- License: gpl-3.0
- Created: 2021-11-14T22:08:57.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-05-04T09:05:47.000Z (about 1 year ago)
- Last Synced: 2025-01-17T09:22:16.310Z (5 months ago)
- Language: D
- Size: 521 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README

# Alchemy
Database converter.
## Import formats
* SQL
* CSV## Export formats
* Basil
* CSV
* Text## Scripting
### Sample
Data processing scripts can be defined in a JavaScript-subset language.
```javascript
let file_text = "";for ( let table_index = 0;
table_index < schema.TableCount;
++table_index )
{
let table = schema.TableArray[ table_index ];if ( table.Name == "CHARACTER" )
{
file_text +=
"CHARACTER\n\n Id Slug FirstName LastName Description Race Comment\n";for ( let row_index = 0;
row_index < table.RowCount;
++row_index )
{
let row = table.RowArray[ row_index ];
let next_row = table.GetRow( row_index + 1 );
let slug = GetSlugCaseText( row.GetValue( "FirstName" ) + "-" + row.GetValue( "LastName" ) + "-character" );file_text +=
"\n"
+ " %" + slug + "\n"
+ " ~ " + slug + "\n"
+ " ~ " + GetBasilText( row.GetValue( "FirstName" ) ) + "\n"
+ " ~ " + GetBasilText( row.GetValue( "LastName" ) ) + "\n"
+ " ~ " + GetBasilText( row.GetValue( "Description" ) ) + "\n"
+ " ~ " + GetBasilText( row.GetValue( "Comment" ) ) + "\n";
}
}
}WriteText( "character_js.bd", file_text );
```### Classes
```javascript
ROWColumnCount
NameArray
ValueArrayAddColumn( name, value )
GetValue( name )TABLE
Name
RowCount
RowArray
DefaultRow
ColumnCount
ColumnNameArrayAddRow( row )
GetRow( row_index )SCHEMA
TableCount
TableArrayAddTable( table )
```### Functions
```javascript
PrintLine( text )
GetInteger( text )
GetReal( text )
ContainsText( text, searched_text )
HasPrefix( text, prefix )
HasSuffix( text, suffix )
GetPrefix( text, separator )
GetSuffix( text, separator )
RemovePrefix( text, prefix )
RemoveSuffix( text, suffix )
ReplacePrefix( text, old_prefix, new_prefix )
ReplaceSuffix( text, old_suffix, new_suffix )
ReplaceText( text, old_text, new_text )
GetStrippedText( text )
GetLeftStrippedText( text )
GetRightStrippedText( text )
GetMinorCaseText( text )
GetMajorCaseText( text )
GetLowerCaseText( text )
GetUpperCaseText( text )
GetPascalCaseText( text )
GetCamelCaseText( text )
GetSnakeCaseText( text )
GetKebabCaseText( text )
GetSlugCaseText( text )
GetFileCaseText( text )
GetBasilText( text )
GetCsvText( text )
ReadText( file_path )
WriteText( file_path, text )
```## Installation
Install the [DMD 2 compiler](https://dlang.org/download.html) (using the MinGW setup option on Windows).
Build the executable with the following command line :
```bash
dmd -m64 alchemy.d
```## Command line
```
alchemy [options]
```### Options
```
--read-sql : read an SQL data file
--read-csv : read a CSV data file
--write-bd : write a Basil data file
--write-csv : write a CSV data file
--write-js : write a JS script
--run-js <script file path> : run a JS script
```### Examples
```bash
alchemy --read-sql blog.sql --write-bd blog.bd
```Reads an SQL data file and writes a Basil data file.
```bash
alchemy --read-sql blog.sql --write-csv blog_article.csv ARTICLE --write-csv blog_comment.csv COMMENT
```Reads an SQL data file and writes CSV data files.
```bash
alchemy --read-csv character.csv --write-bd character.bd
```Reads a CSV data file and writes a Basil data file.
```bash
alchemy --read-csv character.csv --run-js character.js
```Reads a CSV data file and runs a JavaScript-subset file.
## Version
0.5
## Author
Eric Pelzer ([email protected]).
## License
This project is licensed under the GNU General Public License version 3.
See the [LICENSE.md](LICENSE.md) file for details.