Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sassman/edu-sql-parser-rs
SQL Types transpiles `CREATE TABLE` SQL code into type definitions in other languages such as TypeScript or Rust.
https://github.com/sassman/edu-sql-parser-rs
compiler languages parser rust sql sql-parser transpiler typegen typescript
Last synced: 3 days ago
JSON representation
SQL Types transpiles `CREATE TABLE` SQL code into type definitions in other languages such as TypeScript or Rust.
- Host: GitHub
- URL: https://github.com/sassman/edu-sql-parser-rs
- Owner: sassman
- Created: 2020-10-29T23:56:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2020-11-10T08:32:22.000Z (about 4 years ago)
- Last Synced: 2024-12-04T15:48:48.665Z (2 months ago)
- Topics: compiler, languages, parser, rust, sql, sql-parser, transpiler, typegen, typescript
- Language: Rust
- Homepage:
- Size: 16.6 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## SQL Types
WIP: SQL Types transpiles `CREATE TABLE` SQL code into type definitions in other languages such as TypeScript or Rust.
## Syntax
Basic syntax rules:
```ebnf
::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9::= a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | p | q | r | s | t | u | v | w | x | y | z | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
::= !!any character.
::= $
::= "
::= _
::= |
::= { | } [{ | | | | }...]
::= ...
// note: original definition is instead of
::=
```### Create Table Syntax
Currently Work in progress
```
// simplified version
CREATE [ ]
[
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[COMMENT ]
[]
[]// simplified version
::= [ COLUMN ] TABLE
::= [.]// simplified version
::=
(, ...) []::=
[ ]
|::= { | }
[ ]
[ ]
[ ]
[ | ]
[ ]
[ ]
[ ]
[ ]
[ ]
[ COMMENT ]
[ ]
[ ]
::=::=
DATE
| TIME
| SECONDDATE
| TIMESTAMP
| TINYINT
| SMALLINT
| INT
| BIGINT
| SMALLDECIMAL
| REAL
| DOUBLE
| TEXT
| BINTEXT
| VARCHAR [ () ]
| NVARCHAR [ () ]
| ALPHANUM [ () ]
| VARBINARY [ () ]
| SHORTTEXT [ () ]
| DECIMAL [ ( [, ]) ]
| FLOAT [ () ]
| BOOLEAN::= DEFAULT
::=
NULL
|
|
|::=
CURRENT_DATE
| CURRENT_TIME
| CURRENT_TIMESTAMP
| CURRENT_UTCDATE
| CURRENT_UTCTIME
| CURRENT_UTCTIMESTAMP
::=::=
NULL
| NOT NULL
| { HIDDEN | NOT HIDDEN }
| [ ]
| [ ]
::=
UNIQUE [ ]
| PRIMARY KEY [ | ]::= { BTREE | CPBTREE }
::= INVERTED [ ]
::= { HASH | VALUE | INDIVIDUAL }```
[hana/sql]: https://help.sap.com/doc/9b40bf74f8644b898fb07dabdd2a36ad/2.0.04/en-US/SAP_HANA_SQL_Reference_Guide_en.pdf
## Usage
there is a little interactive shell to enter SQL and get parsed AST expressions back.
```sh
❯ cargo run
>>> x
Parsing error at line 1 column 1. No repair sequences found.
>>> CREATE TABLE abc(A INT)
Expr (create table): abc
```## License
- **[GNU GPL v3 license](https://www.gnu.org/licenses/gpl-3.0)**
- Copyright 2020 © [Sven Assmann][2].[2]: https://www.d34dl0ck.me
[4]: https://github.com/sassman/sql-types-rs/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22
[5]: https://github.com/sassman/sql-types-rs/issues/new/choose