Michael Olson <[EMAIL PROTECTED]> writes:

Ok, so heres some proof of concept code:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; jdbc urls
(defun planner-browse-url-jdbc (url)
  "Browse JDBC URLs."
  ;; code for browsing JDBC URLs
  ;; url to test  with:
  (string-match 
"jdbc:\\([^:/]*\\)://\\([^/]*\\)/\\([^?]*\\).user=\\([^&]*\\)&password=\\(.*\\)"
 url)
  (let
      ((driver (match-string 1 url))
       (sql-server   (match-string 2 url))
       (sql-database   (match-string 3 url))
       (sql-user   (match-string 4 url))
       (sql-password   (match-string 5 url))
       )
      (message "jdbc url:%s driver:%s host:%s db:%s usr:%s pwd:%s" url driver 
sql-server sql-database sql-user sql-password)
      (sql-postgres)
    )
  )


;jdbc:\\([^:/]*\\)://\\([^/]*\\)/\\([^?]*\\).user=\\([^&]*\\)&password=\\(.*\\)
(defun planner-resolve-url-jdbc (url)
  "Resolve JDBC URLs."
  ;; Turn a JDBC URL into an http:// URL, if applicable
  ;; Otherwise omit this and use 'identify below
nil)

(planner-add-protocol "jdbc:" 'planner-browse-url-jdbc
                                'planner-resolve-url-jdbc)


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
So if you activate a url like:
jdbc:postgresql://localhost/pgdatabase?user=demo&password=demo

it will open that server in sql mode.

TODO:
- driver is just ignored, should for to the correct postgres/mssql
whatever driver function. currently it just does postgres
- sql mode prompts for arguments, with the data suplied in the jdbc
url as defaults, I would rather not have it prompt.
- the sql buffer name should become the database name
- the url syntax is very rigid, but the jdbc url spec is less rigid



> [EMAIL PROTECTED] writes:
>
>> It would be useful to have jdbc,or something similar, url support in planner.
>>
>> It would be similar to http urls and ir urls.
>>
>> What would be he steps to add this?
>
> (defun planner-browse-url-jdbc (url)
>   "Browse JDBC URLs."
>   ;; code for browsing JDBC URLs
> )
>
> (defun planner-resolve-url-jdbc (url)
>   "Resolve JDBC URLs."
>   ;; Turn a JDBC URL into an http:// URL, if applicable
>   ;; Otherwise omit this and use 'identify below
> )
>
> (planner-add-protocol "jdbc://" 'planner-browse-url-jdbc
>                                 'planner-resolve-url-jdbc)
>
> -- 
> Michael Olson -- FSF Associate Member #652 -- 
> http://www.mwolson.org/Interests: Emacs Lisp, text markup, protocols -- 
> Jabber: mwolson_at_hcoop.net
>   /` |\ | | | IRC: freenode.net/mwolson: #emacs, #hcoop, #muse, #PurdueLUG
>  |_] | \| |_| Projects: Emacs, Muse, ERC, EMMS, Planner, ErBot, DVC
> _______________________________________________
> Planner-el-discuss mailing list
> [email protected]
> https://mail.gna.org/listinfo/planner-el-discuss

-- 
Joakim Verona
http://www.verona.se


_______________________________________________
Planner-el-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/planner-el-discuss

Reply via email to