Update wgexport
This commit is contained in:
@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
import decimal
|
||||
import pypyodbc
|
||||
|
||||
#pypyodbc.lowercase = False
|
||||
|
||||
|
||||
def convert(a) -> str:
|
||||
if type(a) == str:
|
||||
@ -13,6 +13,13 @@ def convert(a) -> str:
|
||||
return "T" if a else "F"
|
||||
elif a is None:
|
||||
return ""
|
||||
elif type(a) == datetime.datetime:
|
||||
if a.year == 1899 and a.month == 12 and a.day == 30:
|
||||
return a.strftime('%H:%M:%S')
|
||||
elif a.hour == 0 and a.minute == 0 and a.second == 0:
|
||||
return a.strftime('%Y-%m-%d')
|
||||
else:
|
||||
return str(a)
|
||||
else:
|
||||
return str(a)
|
||||
|
||||
@ -22,10 +29,8 @@ if __name__ == '__main__':
|
||||
parser.add_argument('wgdaten')
|
||||
args = parser.parse_args()
|
||||
|
||||
conn = pypyodbc.connect(
|
||||
r"Driver={Microsoft Access Driver (*.mdb, *.accdb)};" +
|
||||
f"Dbq={args.wgdaten};")
|
||||
|
||||
pypyodbc.lowercase = False
|
||||
conn = pypyodbc.connect(f"Driver={{Microsoft Access Driver (*.mdb, *.accdb)}};Dbq={args.wgdaten};")
|
||||
cur = conn.cursor()
|
||||
|
||||
try:
|
||||
@ -34,6 +39,7 @@ if __name__ == '__main__':
|
||||
for file, _, t_name, t_type, _ in tbls:
|
||||
print(t_name)
|
||||
cur.execute(f"SELECT * FROM {t_name};")
|
||||
print([(t[0], t[1]) for t in cur.description])
|
||||
cols = [t[0] for t in cur.description]
|
||||
|
||||
with open(f'tables/{t_name}.csv', 'wb+') as f:
|
||||
|
Reference in New Issue
Block a user