Skip to content

Commit

Permalink
Update or_wraper.py
Browse files Browse the repository at this point in the history
Close #7
  • Loading branch information
muscodev authored Mar 16, 2023
1 parent 2f558a7 commit 07949b1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dbwraper/or_wraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ def select(self,query,cur,con,rtype=None,header=0):
else:
return [list(x) for x in data],1,head
return data,1,head

def sel_to_IOstring(self,query,cur,con,fdata:Tuple=None,arraysize:int=500,headcase=str.upper):

@with_connection.select
def sel_to_IOstring(self,query,cur,con,fdata:Tuple=None,arraysize:int=500,headcase=str.upper,csv_header:bool=False):
"""
Return:
=> StringIO,status,heads
Expand All @@ -190,8 +191,11 @@ def sel_to_IOstring(self,query,cur,con,fdata:Tuple=None,arraysize:int=500,headca
self.error=str(E)
return None,0,head
else:
head = [headcase(x[0]) for x in cur.description]
sio = StringIO()
writer = csv.writer(sio)
if csv_header:
writer.writerows([head])
if not fdata:
writer.writerows(cur.fetchall())
else:
Expand All @@ -200,7 +204,7 @@ def sel_to_IOstring(self,query,cur,con,fdata:Tuple=None,arraysize:int=500,headca
sio.count = cur.rowcount
sio.len = sio.tell()
sio.seek(0)
return sio,1,[headcase(x[0]) for x in cur.description]
return sio,1,head



Expand Down

0 comments on commit 07949b1

Please sign in to comment.