Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to Chapel 1.21 #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .gitignore
100644 → 100755
Empty file.
Empty file modified LICENSE
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion Makefile
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pgsql:

#WArning, you should run `mysql_config --cflags --libs` in order to know the library path
mysqlex:
chpl -o ./bin/mysqlex ./example/exmysql.chpl ./src/mysql_helper.c ./src/mysql_helper.c -M ./src -I./src -I/usr/include/mysql -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl
chpl -o ./bin/mysqlex ./example/exmysql.chpl ./src/mysql_helper.c ./src/mysql_helper.c -M ./src -I./src -I/usr/include/mysql -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -lssl -lcrypto -ldl

update_mysql_ex:
chpl -o ./bin/update_mysql_ex ./example/update_mysql_ex.chpl -M ./src ./src/mysql_helper.c -I./src -I/usr/include/mysql -L/usr/lib/x86_64-linux-gnu -lmysqlclient -lpthread -lz -lm -lrt -latomic -ldl
Expand Down
8 changes: 8 additions & 0 deletions Mason.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

[root]
name = "Cdo"
version = "0.1.1"
chplVersion = "1.20.0..1.20.0"
authors = ["Marcos Cleison Silva Santana <[email protected]>"]


Empty file modified Mason.toml
100644 → 100755
Empty file.
12 changes: 8 additions & 4 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ On Ubuntu do:
sudo apt-get install libpq-dev
```
3. Go to example/expq.chpl and inform database host, user, password.
4. Go to repository folder and compile:
4. Import database
```bash
psql teste < postgreData.sql
```
5. Go to repository folder and compile:
```bash
make pgsql
```
5. Run the example:
6. Run the example:
```bash
./expq
```
Expand Down Expand Up @@ -117,8 +121,8 @@ var cursor = con.cursor();
//Queries from database
cursor.query("SELECT * FROM contacts");
//Get one row.
var res:Row = cursor.fetchone();
while(res.isValid()){
var res: Row? = cursor.fetchone();
while(res != nil){
//print the results.
writeln(res);
//get the next row one.
Expand Down
Empty file modified doc/.nojekyll
100644 → 100755
Empty file.
Empty file modified example/array_agg_pg.chpl
100644 → 100755
Empty file.
Empty file modified example/delete_mysql_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/delete_pg_ex.chpl
100644 → 100755
Empty file.
18 changes: 14 additions & 4 deletions example/exmysql.chpl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,33 @@ proc main(){
//Queries from database
cursor.query("SELECT * FROM contacts");
//Get one row.
var res: Row = cursor.fetchone();
while(res.isValid()){
var res: Row? = cursor.fetchone();
if(res != nil) {
try! {
const r = res: shared Row;
writeln("name = ", r["name"]," email = ", r["email"] );
}
}
while(res != nil){
//print the results.
writeln(res);

//get the next row one.
res = cursor.fetchone();

}

// Queries passing tuple to formated query string.
cursor.query("SELECT %s, %s FROM contacts",("email","name"));
// writeln(cursor);
// iterate over all rows
for row in cursor{
for row in cursor {
res = row;
//get row data by column name and print it.
writeln("name = ", row["name"]," email = ", row["email"] );
}

writeln("Checking ");
writeln("name = ", res!["name"]," email = ", res!["email"] );
cursor.query("SELECT * FROM contacts");

// iterate over all rows
Expand Down
4 changes: 2 additions & 2 deletions example/expq.chpl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ module Main{
//Queries from database
cursor.query("SELECT * FROM public.contacts");
//Get one row.
var res: Row = cursor.fetchone();
while(res.isValid()) {
var res: Row? = cursor.fetchone();
while(res != nil) {
//print the results.
writeln(res);
//get the next row one.
Expand Down
Empty file modified example/exsqlite.chpl
100644 → 100755
Empty file.
Empty file modified example/insert_mysql_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/insert_pg_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/model_mysql_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/model_pg_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/model_pg_ex2.chpl
100644 → 100755
Empty file.
Empty file modified example/model_pg_ex3.chpl
100644 → 100755
Empty file.
Empty file modified example/query_builder_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/query_builder_mysql_ex.chpl
100644 → 100755
Empty file.
Empty file modified example/teste.chpl
100644 → 100755
Empty file.
Empty file modified example/update_mysql_ex.chpl
100644 → 100755
Empty file.
1 change: 1 addition & 0 deletions example/update_pg_ex.chpl
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Main{
use Cdo;
use Postgres;
use Map;

proc main(){
//Open connection with Postgres database. Parametrs are host,username, database, password
Expand Down
11 changes: 6 additions & 5 deletions mysqlData.sql
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
CREATE TABLE IF NOT EXISTS "contacts" (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`name` TEXT,
`email` TEXT,
`age` INTEGER
CREATE TABLE IF NOT EXISTS contacts (
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
`name` TEXT,
`email` TEXT,
`age` INTEGER
);

INSERT INTO contacts VALUES(1,'Marcos','[email protected]',35);
INSERT INTO contacts VALUES(2,'Paulo','[email protected]',28);
Empty file modified postgreData.sql
100644 → 100755
Empty file.
Loading