Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Say you've started an open source project and are posting it on a public repository. (like I have, using Codeplex.)

One of the key files just makes the connection to the database, contains the login/password, and is just included from any other source file that needs a database connection.

What's the best way to share the project without giving out your password?

So far I've specifically removed it before committing any changes, but I'm thinking there has to be a better way.

share|improve this question
add comment

4 Answers

up vote 6 down vote accepted

One trick learned in the ASP classic days, was to have the connection string in an outside file.

''// Init the ADO objects  & the stored proc parameters
cmd.ActiveConnection = "file name=c:\udl\mydb.udl"
cmd.CommandText = sqlstmt
cmd.CommandType = adCmdStoredProc
....

It works in ADO, don't know your environment

share|improve this answer
    
I do this with PHP: put the connection string in a config file. –  Frank Shearar Oct 18 '10 at 20:39
    
Thanks.. I did try this also, just thought there might be a better way. This is what I'll do, and document the requirement in the project. –  Fosco Oct 18 '10 at 21:54
2  
Further to this - it also means you don't tie the connection to the source code, which is - generally - a bad thing. You want to easily be able to specify your connection details on a per instance basis and therefore to design this kind of separation in from the start. –  Murph Oct 19 '10 at 7:47
add comment

It sounds to me like you're sharing your code, but not the connection.

You may want to just store your password in a file outside your checkout or a file that is marked as ignored by your version control. I have a set of scripts at work that need my username/password that I shared, and I just have it look at ~/.live_db to get my info.

share|improve this answer
add comment

If you're using windows you can encrypt the connection string (e.g. like this) and share that but not the encryption key. I dare say that other platforms have similar capabilities.

Of course it'll be a waste of time unless that account is also locked down with limited privilages.

share|improve this answer
add comment

If you are sharing the uname and pwd, you should probably consider saving them in encrypted form.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.