Tell me more ×
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.

What are the most well known / commonly accepted variable names used for the SQL connection itself?

  • In Perl, I have seen $dbh (stands for database handle, but why 'handle'), which has been used only for this purpose: only for databases, nothing else.
  • In Java, I have seen things like connection, con, c; all of which could be used for non-SQL connections as well, and are therefore slightly subject to name collisions, requiring a break from the pattern.

I could use a variable name like sql (unusual, but pretty clear), or sqlConnection (uncomfortably long), but I wanted to see if there is any obvious standard I am missing out on?

Do most programmers besides myself have a clear idea of what dbh means? Should I just use sql? Do you think I really ought to spell it out as sqlConnection?

share|improve this question
1  
Every programming language has its own idioms and naming standards. You're extremely unlikely to find a naming standard which applies to all languages. Some languages prefer clarity and have no regard for verbosity, and might call the variable myDatabaseConnection. Other languages might value terseness and call it simply db. The important thing is to be consistent with the idioms of your particular project/company/language. – MattDavey Jan 31 at 14:51

closed as not constructive by GlenH7, MattDavey, Glenn Nelson, BЈовић, gnat Jan 31 at 15:12

As it currently stands, this question is not a good fit for our Q&A; format. We expect answers to be supported by facts, references, or specific expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, see the FAQ for guidance.

1 Answer

up vote 4 down vote accepted

There is no "obvious standard", everybody makes their own choice.

I usually use db, as it is short and unambiguous.

share|improve this answer
I also vote for db :) – Napolux Jan 31 at 14:51

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