Hi Kris et al, On Wed, 25 Apr 2001 17:28:22 -0500 (CDT) Kris Hagel <hagel@cyclotronmail.tamu.edu> wrote concerning ": Fwd: Error Condition Re: Re: question": ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ||||||||||||||||||||||||||||||||||||| Pawel, please change subject lines to something meaningful for the topic at hand. > Pawel, > One good way is to connect to the runDB and get the run and then > extract the sequences from it. I have attached a macro that does > just that and has in fact been used to test the db software. It > works. Give it a try. A note on that script. (I really don't like the term "macro". A macro is something that's expanded from plain text to plain text. A script is something that is interpreted, like CINT/ROOT scripts.) You have #define USER_NAME "query" #define PASSWORD "query-only" ... cout << "Connecting to main database" << endl; BrMainDb* mainDb = new BrMainDb(USER_NAME, PASSWORD, MAIN_HOST, MAIN_NAME); cout << "Connecting to run database" << endl; BrRunsDb* runDb = mainDb->ConnectToRun("query","query-only"); That is not a good idea. I know that's what we had to do earlier, but nowm with BrDB::ReadUserPasswd it's no longer needed, and indeed depreciated. In fact, BrDB::ReadUserPasswd has been in BRAT for quite some time now, see my message from Mon Mar 05 2001 - 13:23:05 EST @ http://www.rhic.bnl.gov/brahms/WWW/private/list_hyper/brahms-dev-l/0828.html which also describes the stuff in some detail. Put the file .bratdbrc in your home directory, change the mode to be 0600 (user read+write, nothing else), and put lines giving host, database, user and password. prompt% cd ${HOME} prompt% echo "" > .bratdbrc prompt% chmod 0600 .bratdbrc prompt% <your favorite editor i.e., emacs> .bratdbrc # lines starting with '#' are comments and ignored. # # Each line is of the form # <host> <db> <user> <password> # # Official BRAHMS Run database pii3.brahms.bnl.gov RUNDB query query-only # Temporary BRAHMS main and calibration database pii3.brahms.bnl.gov BrahmsMain query query-only pii3.brahms.bnl.gov BrahmsCalib query query-only # Local mirrors some.machine.locally BrahmsMain query query-only some.machine.locally BrahmsCalib query query-only some.machine.locally RUNDB query query-only # Others? BrDB::ReadUserPasswd will look for a line with mathing host and database, and if the user is also given, the line must also match the user. The password is then read of the line and used for authentification with the MySQL server. If BrDB::ReadUserPasswd can not find a matching line, then it will prompt the user with User (for <DB>@<host>): Password (for <user>@<host>): Please note that BrDB::ReadUserPasswd is private, so you can not send that message explicitly. However, it is send every time you try to connect to a database. In your code, you should put cout << "Connecting to main database" << endl; BrMainDb* mainDb = new BrMainDb("", "", MAIN_HOST, MAIN_NAME); cout << "Connecting to run database" << endl; BrRunsDb* runDb = mainDb->ConnectToRun("", ""); That's it. The idea is that you should not have literal passwords in the code (security reasons, it may change, and so on), and you should be able to supply user name and password non-interactively (on the CRS for example). The idea is taken from TAuthenticate in ROOT. See also BrDb HTML documentation (version 1.14, or later I believe) for more information. Also see applications in dbapps for more on how to interface the databases. Yours, Christian ----------------------------------------------------------- Holm Christensen Phone: (+45) 35 35 96 91 Sankt Hansgade 23, 1. th. Office: (+45) 353 25 305 DK-2200 Copenhagen N Web: www.nbi.dk/~cholm Denmark Email: cholm@nbi.dk
This archive was generated by hypermail 2b29 : Thu Apr 26 2001 - 07:21:58 EDT