Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/scientifichackers/sql2code
Convert SQL to import-able code!
https://github.com/scientifichackers/sql2code
Last synced: 3 days ago
JSON representation
Convert SQL to import-able code!
- Host: GitHub
- URL: https://github.com/scientifichackers/sql2code
- Owner: scientifichackers
- License: mit
- Created: 2019-11-07T15:32:02.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-07T15:34:53.000Z (about 5 years ago)
- Last Synced: 2024-10-12T04:55:18.753Z (about 1 month ago)
- Language: Python
- Size: 4.88 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQL 2 code
This project lets you write functions in SQL and import them in code.
Currently, it only supports dart.
```console
$ pip install sql2code
``````sql
-- queries1.sql
listMessages(sender, limit, offset) {
SELECT *
FROM message
WHERE sender = $sender
ORDER BY sentAt
LIMIT $limit OFFSET $offset;
}
``````console
$ sql2dart quries.sql queries.dart
``````dart
// queries.dart
import 'package:sqflite/sqflite.dart';Future>> listMessages(
Database db,
sender,
limit,
offset,
) async {
return await db.transaction((txn) async {
return await txn.rawQuery(
"""SELECT * FROM message WHERE sender = ? ORDER BY sentAt LIMIT ? OFFSET ? """,
[sender, limit, offset],
);
});
}
```