1- # -*- coding: utf-8 -*-
21
32import os
43from contextlib import contextmanager
54
6- from sqlalchemy import create_engine , exc , inspect , text
5+ from sqlalchemy import create_engine , inspect , text
76
87from .record import Record , RecordCollection
98
109
11- class Database ( object ) :
10+ class Database :
1211 """Main interface for database operations."""
1312
1413 def __init__ (self , db_url = None , ** kwargs ):
@@ -62,12 +61,12 @@ def bulk_query(self, query, *multiparams):
6261 return conn .bulk_query (query , * multiparams )
6362
6463 def query_file (self , path , fetchall = False , ** params ):
65- with open (path , "r" ) as f :
64+ with open (path ) as f :
6665 query = f .read ()
6766 return self .query (query , fetchall = fetchall , ** params )
6867
6968 def bulk_query_file (self , path , * multiparams ):
70- with open (path , "r" ) as f :
69+ with open (path ) as f :
7170 query = f .read ()
7271 return self .bulk_query (query , * multiparams )
7372
@@ -85,7 +84,7 @@ def transaction(self):
8584 conn .close ()
8685
8786
88- class Connection ( object ) :
87+ class Connection :
8988 def __init__ (self , connection , close_with_result = False ):
9089 self ._connection = connection
9190 self ._close_with_result = close_with_result
@@ -124,12 +123,12 @@ def bulk_query(self, query, *multiparams):
124123 return result
125124
126125 def query_file (self , path , fetchall = False , ** params ):
127- with open (path , "r" ) as f :
126+ with open (path ) as f :
128127 query = f .read ()
129128 return self .query (query , fetchall = fetchall , ** params )
130129
131130 def bulk_query_file (self , path , * multiparams ):
132- with open (path , "r" ) as f :
131+ with open (path ) as f :
133132 query = f .read ()
134133 return self .bulk_query (query , * multiparams )
135134
0 commit comments