Skip to content

Commit

Permalink
updated renamed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
drkameleon committed Oct 31, 2020
1 parent b74b123 commit 8eb6841
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion info.art
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
description: "Db management module for Arturo"
version: "0.1"
version: "0.1.2"
dependencies: []
author: "Yanis Zafirópulos"
20 changes: 11 additions & 9 deletions main.art
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
;-------------------------------

db: function [name,block][
dbobj: dbOpen name
dbobj: open name

create: function [table,contents][
fields: []
Expand All @@ -22,24 +22,26 @@ db: function [name,block][
]
fields: join.with:", " fields

query: ~"DROP TABLE IF EXISTS |table|"
dbExec dbobj query
q: ~"DROP TABLE IF EXISTS |table|"
query dbobj q

query: ~"CREATE TABLE |table| (|fields|)"
dbExec dbobj query
q: ~"CREATE TABLE |table| (|fields|)"
query dbobj q
]

insert: function [table,contents][
details: #contents
tableKeys: join.with:", " select keys details 'x -> is? :string details \ x
tableValues: join.with:", " map (select values details 'x -> is? :string x) 'x -> ~"\"|x|\""

query: ~"INSERT INTO |table| (|tableKeys|) VALUES (|tableValues|)"
q: ~"INSERT INTO |table| (|tableKeys|) VALUES (|tableValues|)"

dbExec dbobj "BEGIN"
dbExec dbobj query
dbExec dbobj "COMMIT"
query dbobj "BEGIN"
query dbobj q
query dbobj "COMMIT"
]

do block

close dbobj
]

0 comments on commit 8eb6841

Please sign in to comment.