Skip to content

Commit

Permalink
minor refectoring
Browse files Browse the repository at this point in the history
  • Loading branch information
bart mosley committed Aug 2, 2011
1 parent e0a7508 commit 22b8e2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ def connect(self, dbtype, *args, **kwargs):
import sqlite3
self.connection = sqlite3.connect(*args, **kwargs)
self.lastrowid_ = "LAST_INSERT_ROWID()"

elif dbtype == 'mysql':
import MySQLdb
self.connection = MySQLdb.connect(**kwargs)
self.lastrowid_ = "LAST_INSERT_ID()"
self.placeholder = '%s'

elif dbtype == 'pyodbc':
import pyodbc
self.connection = pyodbc.connect(**kwargs)
Expand Down
6 changes: 4 additions & 2 deletions model.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __new__(cls, name, bases, attrs):
if not getattr(new_class.Meta, 'table', None):
new_class.Meta.table = name.lower()
new_class.Meta.table_safe = escape(new_class.Meta.table)

# Assume id is the default
if not getattr(new_class.Meta, 'pk', None):
new_class.Meta.pk = 'id'
Expand All @@ -54,7 +54,9 @@ def __new__(cls, name, bases, attrs):
new_class.db = autumn_db

db = new_class.db
q = Query.raw_sql('SELECT * FROM %s LIMIT 1' % new_class.Meta.table_safe, db=new_class.db)
q = Query.raw_sql('SELECT * FROM %s LIMIT 1' % new_class.Meta.table_safe,
db=new_class.db)

new_class._fields = [f[0] for f in q.description]

if getattr(new_class.Meta, 'inner_join', None):
Expand Down

0 comments on commit 22b8e2f

Please sign in to comment.