~oly/scaffold/trunk

« back to all changes in this revision

Viewing changes to scaffold/core/data/database.py

  • Committer: Oliver Marks
  • Date: 2016-09-18 16:32:41 UTC
  • Revision ID: oly@digitaloctave.com-20160918163241-1y6lhshwr3ucn2tz
python3 changes, fixes to tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
        if connection_details.get('location') is not None:
38
38
            connection_details['host'] = connection_details['location']
39
39
            del(connection_details['location'])
40
 
        
 
40
 
41
41
        self.use_commit = True
42
42
 
43
43
        #mysql database
48
48
                user = connection_details.get('user'),
49
49
                passwd = connection_details.get('passwd'),
50
50
                db = connection_details.get('db'),
51
 
                charset = connection_details.get('charset'),
 
51
                #charset = connection_details.get('charset', 'utf-8'),
52
52
                port = connection_details.get('port', 3306))
53
 
            
 
53
            self.connection.set_charset('utf8')
54
54
            self.cursor = self.connection.cursor(MySQLdb.cursors.DictCursor)
55
55
            return self
56
56
 
57
57
        #sqllite database
58
58
        if dbtype == 'sqllite':
59
59
            db.dbtype = DBTYPE_SQLLITE
60
 
            self.use_commit = False
 
60
            #self.use_commit = False
61
61
            self.connection = sqlite3.connect(connection_details['host'])
62
62
            self.connection.row_factory = sqlite3.Row
63
63
            self.cursor = self.connection.cursor()
124
124
    def execute_query(self, sql, values):
125
125
        try:    
126
126
            self.cursor.execute(sql, values)
 
127
            self.commit()
127
128
        except MySQLdb.Error as e:
128
129
            print(e)
129
130
            print(sql)
145
146
            values = []
146
147
        if self.debug:
147
148
            print(sql.format(values))
148
 
        self.cursor.execute(sql, values)
149
 
                
 
149
        self.execute_query(sql, values)
 
150
        # self.cursor.execute(sql, values)
150
151
        #return self.commit()
151
152
 
152
153
    def insert(self, table, fieldnames=(), values=()):