Browse Source

Add two working SQL queries

master
Christian Fischer 9 months ago
parent
commit
4d46f56f29
2 changed files with 45 additions and 41 deletions
  1. +6
    -4
      server/db.rkt
  2. +39
    -37
      server/resource.rkt

+ 6
- 4
server/db.rkt View File

@@ -3,12 +3,14 @@
(require db
redis)

(provide connect-redis)
(provide connect-redis
connect-sql)

;; This should be a racket parameter
(define (connect-redis)
(make-redis))

;; (define (connect-db)
;; (sqlite3-connect #:database "./proxy.db"
;; #:mode 'create))
(define (connect-sql)
(mysql-connect #:user "gn2"
#:password "gn2"
#:database "db_webqtl_s"))

+ 39
- 37
server/resource.rkt View File

@@ -132,13 +132,15 @@
(define no-access-action
(action "no-access"
(lambda (data params)
'no-access)))
'no-access)
'()))

;; Actions for file-based resources
(define view-file
(action "view"
(lambda (data params)
(file->string (hash-ref data 'path) #:mode 'text))))
(file->string (hash-ref data 'path) #:mode 'text))
'()))

(define edit-file
(action "edit"
@@ -200,38 +202,38 @@



;; (define (select-publish dbc dataset-id trait-name)
;; (query-row dbc
;; "SELECT
;; PublishXRef.Id, InbredSet.InbredSetCode, Publication.PubMed_ID,
;; Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description,
;; Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation,
;; Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users,
;; Publication.Authors, Publication.Title, Publication.Abstract,
;; Publication.Journal, Publication.Volume, Publication.Pages,
;; Publication.Month, Publication.Year, PublishXRef.Sequence,
;; Phenotype.Units, PublishXRef.comments
;; FROM
;; PublishXRef, Publication, Phenotype, PublishFreeze, InbredSet
;; WHERE
;; PublishXRef.Id = ? AND
;; Phenotype.Id = PublishXRef.PhenotypeId AND
;; Publication.Id = PublishXRef.PublicationId AND
;; PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND
;; PublishXRef.InbredSetId = InbredSet.Id AND
;; PublishFreeze.Id = ?"
;; trait-name
;; dataset-id))
;; (define (select-geno dbc dataset-name trait-name)
;; (query-row dbc
;; "SELECT Geno.name Geno.chr Geno.mb Geno.source2 Geno.sequence
;; FROM Geno, GenoFreeze, GenoXRef
;; WHERE GenoXRef.GenoFreezeId = GenoFreeze.Id AND
;; GenoXRef.GenoId = Geno.Id AND
;; GenoFreeze.Name = ? AND
;; Geno.Name = ?"
;; dataset-name
;; trait-name))
(define (select-publish dbc dataset-id trait-name)
(query-rows dbc
"SELECT
PublishXRef.Id, InbredSet.InbredSetCode, Publication.PubMed_ID,
Phenotype.Pre_publication_description, Phenotype.Post_publication_description, Phenotype.Original_description,
Phenotype.Pre_publication_abbreviation, Phenotype.Post_publication_abbreviation,
Phenotype.Lab_code, Phenotype.Submitter, Phenotype.Owner, Phenotype.Authorized_Users,
Publication.Authors, Publication.Title, Publication.Abstract,
Publication.Journal, Publication.Volume, Publication.Pages,
Publication.Month, Publication.Year, PublishXRef.Sequence,
Phenotype.Units, PublishXRef.comments
FROM
PublishXRef, Publication, Phenotype, PublishFreeze, InbredSet
WHERE
PublishXRef.Id = ? AND
Phenotype.Id = PublishXRef.PhenotypeId AND
Publication.Id = PublishXRef.PublicationId AND
PublishXRef.InbredSetId = PublishFreeze.InbredSetId AND
PublishXRef.InbredSetId = InbredSet.Id AND
PublishFreeze.Id = ?"
trait-name
dataset-id))
(define (select-geno dbc dataset-name trait-name)
(query-rows dbc
"SELECT Geno.name, Geno.chr, Geno.mb, Geno.source2, Geno.sequence
FROM Geno, GenoFreeze, GenoXRef
WHERE GenoXRef.GenoFreezeId = GenoFreeze.Id AND
GenoXRef.GenoId = Geno.Id AND
GenoFreeze.Name = ? AND
Geno.Name = ?"
dataset-name
trait-name))

Loading…
Cancel
Save