text stringlengths 0 15.7k | source stringlengths 6 112 |
|---|---|
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"delete from standings" | lns3.scpt |
«event ©±SQ©±Eb» theDb given «class ©±Cq»:"insert into standings values (?, ?, ?, ?)", «class ©±Cg»:theList | lns3.scpt |
set result2 to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from standings" | lns3.scpt |
set result3 to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from standings where country in (?, ?)", «class ©±Cg»:{"Italy", "France"}, «class ©±Cy»:«constant ©±Tt©±Tr» | lns3.scpt |
«event ©±SQ©±Cd» theDb | lns3.scpt |
return {result1, result2, result3} | lns3.scpt |
set thePath to "~/Desktop/Test1.db" | lns3.scpt |
set theDb to «event ©±SQ©±Od» with «class ©±Cc» given «class ©±If»:thePath | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"drop table if exists test" | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"create table test (a text, b text, c integer, d double, e double)" | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?, ?)", «class ©±Cg»:{1, 1, 1, 1, 1} | lns3.scpt |
set imDb to «event ©±SQ©±Od» with «class ©±Cw» and «class ©±Cm» given «class ©±If»:thePath | lns3.scpt |
repeat with i from 1 to 3 | lns3.scpt |
set theDate to (current date) + i * 60 | lns3.scpt |
(«event ©±SQ©±Eu» imDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?, ?)", «class ©±Cg»:{theDate, "number " & i, i, theDate, i + 0.1}) | lns3.scpt |
set thePath2 to "~/Desktop/Test2.db" | lns3.scpt |
«event ©±SQ©±Cw» imDb given «class ©±Tf»:thePath2 -- only works with in-memory databases | lns3.scpt |
«event ©±SQ©±Cd» imDb | lns3.scpt |
set theDb to «event ©±SQ©±Od» given «class ©±If»:thePath | lns3.scpt |
set result1 to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from test" | lns3.scpt |
set otherDb to «event ©±SQ©±Od» given «class ©±If»:thePath2 | lns3.scpt |
set result2 to «event ©±SQ©±Ce» otherDb given «class ©±Cq»:"select * from test" | lns3.scpt |
set result3 to «event ©±SQ©±Ce» otherDb given «class ©±Cq»:"select * from test", «class ©±Cn»:{0, 3} -- zero-based column numbers | lns3.scpt |
on error errMess number errNum from x | lns3.scpt |
«event ©±SQ©±Cd» otherDb | lns3.scpt |
error errMess number errNum from x | lns3.scpt |
set thePath to "~/Desktop/Test.db" | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (1, 1, 1, 1, 1)" | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?, ?)", «class ©±Cg»:{"hi", "number " & 1, 1, current date, 1.1} | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (:a, :b, :c, :d, :e)", «class ©±Ci»:{a:"hello", b:"number " & 1, c:1, d:current date, e:1 + 0.1} | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (:a, :b, :c, :d, :e)", «class ©±Ci»:{a:"hello", b:"number " & i, c:i, d:current date, e:i + 0.1} | lns3.scpt |
repeat with i from 4 to 6 | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?, ?)", «class ©±Cg»:{"hi", "number " & i, i, current date, i + 0.1} | lns3.scpt |
«event ©±SQ©±Eb» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?, ?)", «class ©±Cg»:{¬
{"hi", "number " & 1, 1, current date, 1.1}, ¬ | lns3.scpt |
{"ho", "number " & 2, 2, current date, 2.1}, ¬ | lns3.scpt |
{"hum", "number " & 2, 2, current date, 3.1}} | lns3.scpt |
set theResult to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select a, b from test where a = ?", «class ©±Cg»:{"hi"}, «class ©±Cy»:«constant ©±Tt©±Tr» | lns3.scpt |
on error errMess number errNum | lns3.scpt |
display dialog errMess & " (" & errNum & ")" | lns3.scpt |
set secondResult to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from test", «class ©±Cy»:«constant ©±Tt©±Tr» | lns3.scpt |
set thirdResult to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from test where a = ?", «class ©±Cg»:{"hi"}, «class ©±Cn»:{3}, «class ©±Cy»:«constant ©±Tt©±Tr» | lns3.scpt |
return {theResult, secondResult, thirdResult} | lns3.scpt |
set csvText to "One,Two\",\" two,Three,\"Four \"\"four\"\" four\"" & linefeed & "Five\",\" five,Six,Seven,Eight" & return & "Nine,\"Ten , ten\",Eleven,Twelve" & linefeed & return | lns3.scpt |
set thePath to "~/Desktop/TestCSV1.db" | lns3.scpt |
«event ©±SQ©±Eu» theDb given «class ©±Cq»:"create table test (a, b, c, d)" | lns3.scpt |
«event ©±SQ©±Et» theDb with «class ©±Cv» given «class ©±Cq»:"insert into test values (?, ?, ?, ?)", «class ©±Ca»:csvText | lns3.scpt |
set tempPath to (path to desktop as string) & "TestCSV.txt" | lns3.scpt |
set fileRef to open for access tempPath as «class furl» with write permission | lns3.scpt |
set eof of fileRef to 0 | lns3.scpt |
write csvText to fileRef as «class utf8» | lns3.scpt |
set thePath to "~/Desktop/TestCSV2.db" | lns3.scpt |
«event ©±SQ©±Ef» theDb with «class ©±Cv» given «class ©±Cq»:"insert into test values (?, ?, ?, ?)", «class ©±Ir»:tempPath | lns3.scpt |
set result2 to «event ©±SQ©±Ce» theDb given «class ©±Cq»:"select * from test" | lns3.scpt |
return {result1, result2, result1 = result2} | lns3.scpt |
set tabbedText to "One" & tab & "Two\",\" two" & tab & "Three" & tab & "Four" & linefeed & "Five\",\" five" & tab & "Six" & tab & "Seven" & tab & "Eight" & return & "Nine" & tab & "Ten" & tab & "Eleven" & tab & "Twelve" & linefeed & linefeed & return | lns3.scpt |
set thePath to "~/Desktop/TestTSV1.db" | lns3.scpt |
«event ©±SQ©±Et» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?)", «class ©±Ca»:tabbedText, «class ©±Ck»:tab | lns3.scpt |
set tempPath to (path to desktop as string) & "TestTSV.txt" | lns3.scpt |
write tabbedText to fileRef as «class utf8» | lns3.scpt |
set thePath to "~/Desktop/TestTSV2.db" | lns3.scpt |
«event ©±SQ©±Ef» theDb given «class ©±Cq»:"insert into test values (?, ?, ?, ?)", «class ©±Ir»:tempPath, «class ©±Ck»:tab | lns3.scpt |
on controlTextDidChange:notif | lns3.scpt |
set theField to notif's |object|() | lns3.scpt |
if theField's isEqualTo:firstField then | lns3.scpt |
[...] | lns3.scpt |
end controlTextDidChange: | lns3.scpt |
use AppleScript version "2.3.1" | lns3.scpt |
set newDate to its makeNSDateFrom:(current date) | lns3.scpt |
its makeASDateFrom:newDate | lns3.scpt |
on makeNSDateFrom:theASDate | lns3.scpt |
set {theYear, theMonth, theDay, theSeconds} to theASDate's {year, month, day, time} | lns3.scpt |
if theYear < 0 then set theYear to -theYear | lns3.scpt |
set newDate to theCalendar's dateWithEra:(theYear ≥ 0) |year|:theYear |month|:(theMonth as integer) |day|:theDay hour:0 minute:0 |second|:theSeconds nanosecond:0 | lns3.scpt |
return newDate | lns3.scpt |
end makeNSDateFrom: | lns3.scpt |
on makeASDateFrom:theNSDate | lns3.scpt |
set comps to theCalendar's componentsInTimeZone:(missing value) fromDate:theNSDate | lns3.scpt |
tell (current date) to set {theASDate, year, day, its month, day, time} to ¬ | lns3.scpt |
{it, comps's |year|(), 1, comps's |month|(), comps's |day|(), (comps's hour()) * hours + (comps's minute()) * minutes + (comps's |second|())} | lns3.scpt |
end makeASDateFrom: | lns3.scpt |
use AppleScript version "2.3.1" -- Mavericks (10.9.something) or later | lns3.scpt |
set ASDate to (current date) - 1000000 * days --> A date in January 721 BC on the day of posting. | lns3.scpt |
set newNSDate to makeNSDateFrom(ASDate) | lns3.scpt |
set newASDate to makeASDateFrom(newNSDate) | lns3.scpt |
return {ASDate, newNSDate, newASDate} | lns3.scpt |
on makeNSDateFrom(theASDate) | lns3.scpt |
copy theASDate to recentDate | lns3.scpt |
set recentDate's year to 2000 | lns3.scpt |
set timeAdjustment to (date (theASDate's time string)) - (date (recentDate's time string)) | lns3.scpt |
if (timeAdjustment > 0) then set timeAdjustment to timeAdjustment - days | lns3.scpt |
set theASDate to theASDate + timeAdjustment | lns3.scpt |
set {y, m, d, t} to theASDate's {year, month, day, time} | lns3.scpt |
set theEra to (y > -1) as integer | lns3.scpt |
if (theEra is 0) then set y to 1 - y | lns3.scpt |
return theCalendar's dateWithEra:(theEra) |year|:(y) |month|:(m as integer) |day|:(d) hour:(0) minute:(0) |second|:(t) nanosecond:(0) | lns3.scpt |
end makeNSDateFrom | lns3.scpt |
on makeASDateFrom(theNSDate) | lns3.scpt |
tell comps to set {theEra, y, m, d, h, min, s} to {its era(), its |year|(), its |month|(), its |day|(), its hour(), its minute(), its |second|()} | lns3.scpt |
if (theEra is 1) then | lns3.scpt |
tell (current date) to set {theASDate, its day, its year, its month, its day, its hours, its minutes, its seconds} to {it, 1, y, m, d, h, min, s} | lns3.scpt |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.