-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableToRowMapper.py
More file actions
39 lines (33 loc) · 954 Bytes
/
TableToRowMapper.py
File metadata and controls
39 lines (33 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import re
from HelperFuncs import *
lines = parseTableToLines()
for line in lines:
result = re.search('\\[(.*)\\]',line)
split = line.split()
if result:
name = result.group(1)
else:
name = split[0]
typeStr = split[1].lower()
typeReal = ''
match typeStr:
case 'uniqueidentifier':
typeReal = 'Guid'
case 'datetime':
typeReal = 'DateTime'
case 'date':
typeReal = 'DateTime'
case 'bit':
typeReal = 'bool'
case 'bigint':
typeReal = 'long'
case _:
typeReal = typeStr
if re.match('decimal.*',typeStr):
typeReal = 'decimal'
if re.match('varchar.*',typeStr):
typeReal = 'string'
if 'null' in split[2].lower():
typeReal += '?'
print('{} = x.Field<{}>("{}"),'.format(name,typeReal,name))
input("Enter to close")