Skip to content

Commit

Permalink
[修复]get_columns
Browse files Browse the repository at this point in the history
  • Loading branch information
longfengpili committed Mar 10, 2021
1 parent e85d954 commit c9577be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
8 changes: 3 additions & 5 deletions pydbapi/db/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @Author: chunyang.xu
# @Email: [email protected]
# @Date: 2020-06-02 18:46:58
# @Last Modified time: 2021-03-08 13:16:00
# @Last Modified time: 2021-03-10 17:06:44
# @github: https://github.com/longfengpili

# !/usr/bin/env python3
Expand Down Expand Up @@ -55,9 +55,7 @@ def cur_results(self, cursor, count):

def cur_columns(self, cursor):
desc = cursor.description
columns = None
if desc:
columns = tuple(map(lambda x: x[0].lower(), desc)) # 列名
columns = tuple(map(lambda x: x[0].lower(), desc)) if desc else None # 列名

return desc, columns

Expand Down Expand Up @@ -122,7 +120,7 @@ def execute(self, sql, count=None, verbose=0):
else:
pass

if columns and results:
if columns:
results.insert(0, columns)
try:
conn.commit()
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# @Author: chunyang.xu
# @Email: [email protected]
# @Date: 2020-06-09 16:46:54
# @Last Modified time: 2021-03-08 14:24:34
# @Last Modified time: 2021-03-10 17:13:31
# @github: https://github.com/longfengpili

# !/usr/bin/env python3
Expand All @@ -12,7 +12,7 @@
import shutil
import setuptools

VERSION = '0.0.47'
VERSION = '0.0.48'
PROJECT_NAME = 'pydbapi'

with open('README.md', 'r', encoding='utf-8') as f:
Expand Down
10 changes: 5 additions & 5 deletions tests/mysql/mysql_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# @Author: chunyang.xu
# @Date: 2021-03-08 14:19:01
# @Last Modified by: chunyang.xu
# @Last Modified time: 2021-03-08 16:26:02
# @Last Modified time: 2021-03-10 17:12:02

import os
import pytest
Expand Down Expand Up @@ -50,14 +50,14 @@ def test_selectsql(self):

def test_dumpsql(self):
sqlcompile = SqlMysqlCompile(self.tablename)
sql = sqlcompile.dumpsql(self.columns, './csvdata/pydbapitest.csv', condition='name="apple"')
sql = sqlcompile.dumpsql(self.columns, '/tmp/pydbapitest.csv', condition='name="apple"')
print(sql)

@pytest.mark.skip()
# @pytest.mark.skip()
def test_dumpdata(self):
rows, action, result = self.mysqldb.dumpdata(self.tablename, self.columns, './csvdata/pydbapitest.csv', condition='name="apple"')
rows, action, result = self.mysqldb.dumpdata(self.tablename, self.columns, '/tmp/pydbapitest.csv', condition='name="apple"')
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

def test_loaddata(self):
rows, action, result = self.mysqldb.loaddata(self.tablename, self.columns, './csvdata/pydbapitest.csv')
rows, action, result = self.mysqldb.loaddata(self.tablename, self.columns, '/tmp/pydbapitest.csv')
print(f"【rows】: {rows}, 【action】: {action}, 【result】: {result}")

0 comments on commit c9577be

Please sign in to comment.