database: allow database modules to define a field placeholder

mysql and sqlite3 use different field placeholders (%s vs ?), but
are otherwise similar enough that they can share queries. Push that
into submodules.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database: move update_shorturl from sql to db

update_shorturl is generic and belongs in the db module.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.sqlite3: properly call superclass constructor

The sqlite3 constructor wasn't calling the superclass constructor. Since
it's not actually doing anything other than an assertion check, testing
didn't have a problem.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.mysql: properly take a config dict in constructor

Database modules should take a config dict rather than individual variables.

Also call the constructor using the dict.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.mysql: throw exception after last failed retry

We'll silently fall through if the last connect attempt fails. This
properly raises the exception after the last retry.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database: allow database modules to define auto increment keyword

sqlite3 and mysql have different keywords for auto increment

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.sql: mysql does not let text/blob fields have a default

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
exceptions: use named exceptions instead of Execption

'Error' is not a valid exception name. Use appropriate exceptions
instead of vague 'Exception'.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.sql: rename `type' variable

The collision with the type builtin creates confusion.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.sql: clean up new entry query creation

By using a dict we can simplify the query creation.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.mysql: provide `instantiate' name

Without the `instantiate' name, there's no way to create the mysql object
automatically.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
database.sql: use tuples instead of lists for query arguments

MySQLdb requires tuples for args instead of lists.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>
setup: change dependency to `python_twitter'

There are two twitter packages out there, incompatible with one another.

Fix the dependency to specify the one we expect.

Signed-off-by: Jeff Mahoney <jeffm@jeffreymahoney.com>