Skip to content

Commit

Permalink
using DSN connection strings
Browse files Browse the repository at this point in the history
  • Loading branch information
alprionbart committed Nov 22, 2010
1 parent aefb822 commit 634fcec
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
4 changes: 1 addition & 3 deletions Ipy/dbconnection.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ class DBConnection(object):
def __init__(self, **kwargs):
defaultKeys = {'UID': None,
'PWD': None,
'DATABASE': None,
'DRIVER': "{MySQL ODBC 5.1 Driver}",
'SERVER': "localhost"}
'DSN': None}
defaultErrorString = "DBConnection: Value for %s must be provided"

# if parameters are provided, use them,
Expand Down
14 changes: 14 additions & 0 deletions Ipy/testdb/author.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,18 @@ CREATE TABLE IF NOT EXISTS `author` (
PRIMARY KEY (`id`)
) ;

CREATE TABLE IF NOT EXISTS `books` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`author_id` int(11) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `author_id` (`author_id`)
) ;

CREATE TABLE `transaction` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`book_id` int(11),
`saledate` DATE,
`saletime` TIME,
PRIMARY KEY (`id`)
);
4 changes: 2 additions & 2 deletions Ipy/testdb/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from autumnIpy import Model, DBConnection, Query, Filter, OneToMany, ForeignKey
from autumn.Ipy import Model, DBConnection, Query, Filter, OneToMany, ForeignKey

from alprion import AlprionCfg_

cfg = AlprionCfg_.read('database', ("UID", "PWD"))
cfg['DATABASE'] = 'autumn_test'
cfg['DSN'] = 'AutumnTest'

autumnTestConn = DBConnection(**cfg)

Expand Down
2 changes: 1 addition & 1 deletion Ipy/testdb/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

from autumnIpy.testdb.models import Author, Book, Transaction, autumnTestConn
from autumn.Ipy.testdb.models import Author, Book, Transaction, autumnTestConn

import unittest
import datetime
Expand Down

0 comments on commit 634fcec

Please sign in to comment.