-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using LibPQ, Tables | ||
using ProgressMeter | ||
|
||
function connect_db(db_name) | ||
user = String(UInt8.([106])) * String(UInt8.([118])) * String(UInt8.([111])) | ||
password = user * String(UInt8.([33])) | ||
# host = "jvof" | ||
host = "jvox.vo.nao.ac.jp" | ||
|
||
url = "postgresql://" * user | ||
|
||
if password != "" | ||
url *= ":" * password | ||
end | ||
|
||
url *= "@" * host | ||
url *= "/" * db_name | ||
|
||
return LibPQ.Connection(url) | ||
end | ||
|
||
function get_datasets(conn, threshold) | ||
# threshold is given in GB | ||
|
||
# above the threshold | ||
strSQL = "select dataset_id, file_size, path from cube where binf1=1 and binf2=1 and binf3=1 and binf4=1 and file_size>=$(threshold)*1024*1024*1024. order by file_size desc;" | ||
|
||
res = execute(conn, strSQL) | ||
data = columntable(res) | ||
|
||
return data | ||
end |