https://github.com/souris-dev/chapel-data-object
Database connector for the chapel programming language
https://github.com/souris-dev/chapel-data-object
chapel database
Last synced: about 2 months ago
JSON representation
Database connector for the chapel programming language
- Host: GitHub
- URL: https://github.com/souris-dev/chapel-data-object
- Owner: souris-dev
- License: apache-2.0
- Created: 2020-10-28T02:16:13.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-02-26T09:24:23.000Z (about 4 years ago)
- Last Synced: 2025-03-30T23:43:32.288Z (about 2 months ago)
- Topics: chapel, database
- Language: Chapel
- Homepage:
- Size: 2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Chapel Data Object
Database connector for the Chapel programming language.
This `mason` package aims to provide database connectivity for some
relational database management systems.
Currently, support is planned for MySQL, PostgreSQL and SQLite.
Support for other database management systems can be easily added by
implementing the required interfaces.## Usage examples:
### MySQL
```chapel
module Main {
use DatabaseCommunicator;
use DatabaseCommunicator.DatabaseCommunicationObjects.QueryBuilder; // for Statement class
use MySQL;proc main() throws {
var conHandler = new ConnectionHandler(MySQLConnection, "localhost;testdb;username;password");
var cursor = conHandler.cursor();var createStmt = "CREATE TABLE CONTACTS (id INT PRIMARY KEY, name VARCHAR(10));";
cursor.execute(new Statement(createStmt));
cursor.execute(new Statement("INSERT INTO CONTACTS VALUES (6, 'B');"));var stmt: Statement = new Statement("SELECT * FROM CONTACTS WHERE name = ?1", true);
stmt.setValue(1, "B");
cursor.execute(stmt);for row in cursor.fetchall() {
writeln(row![0], "\t", row![1]);
}cursor.close();
conHandler.commit();
conHandler.close();
}
}
```(For more about the `Statement` class, please see the documentation.)