1616import json
1717import ssl
1818
19+ from sqlalchemy import (Table , Column , Integer , MetaData , select , LargeBinary , Text , BigInteger , literal )
1920from sqlalchemy .dialects import postgresql
2021
21- from sqlalchemy import (Table , Column , Integer , MetaData , select , LargeBinary , Text , BigInteger , literal )
2222from common import get_engine , get_default , get_zone , register_common_cli_params
2323
2424metadata = MetaData ()
2525test_table = Table (
26+ 'test' , MetaData (),
27+ Column ('id' , Integer , primary_key = True , nullable = False ),
28+ Column ('data_str' , Text , nullable = True ),
29+ Column ('masking' , LargeBinary , nullable = True ),
30+ Column ('token_i32' , Integer , nullable = True ),
31+ Column ('data_i32' , Integer , nullable = True ),
32+ Column ('token_i64' , BigInteger , nullable = True ),
33+ Column ('data_i64' , BigInteger , nullable = True ),
34+ Column ('token_str' , Text , nullable = True ),
35+ Column ('token_bytes' , LargeBinary , nullable = True ),
36+ Column ('token_email' , Text , nullable = True ),
37+ )
38+
39+ # _schema_test_table used to generate table in the database with binary column types
40+ _schema_test_table = Table (
2641 'test' , metadata ,
2742 Column ('id' , Integer , primary_key = True , nullable = False ),
28- Column ('data ' , LargeBinary , nullable = True ),
43+ Column ('data_str ' , LargeBinary , nullable = True ),
2944 Column ('masking' , LargeBinary , nullable = True ),
3045 Column ('token_i32' , Integer , nullable = True ),
46+ Column ('data_i32' , LargeBinary , nullable = True ),
3147 Column ('token_i64' , BigInteger , nullable = True ),
48+ Column ('data_i64' , LargeBinary , nullable = True ),
3249 Column ('token_str' , Text , nullable = True ),
3350 Column ('token_bytes' , LargeBinary , nullable = True ),
3451 Column ('token_email' , Text , nullable = True ),
@@ -51,7 +68,7 @@ def print_data(connection, zone_id, columns):
5168 query = select (table_columns )
5269 extra_columns = [i .name for i in test_table .columns if i .name not in default_columns ]
5370 except AttributeError :
54- print ("\n \n {0}\n probably you used incorrect column name\n {0}\n \n " .format ('*' * 30 ))
71+ print ("\n \n {0}\n probably you used incorrect column name\n {0}\n \n " .format ('*' * 30 ))
5572 raise
5673 exit (1 )
5774
@@ -82,7 +99,7 @@ def write_data(data, connection):
8299 if isinstance (data , dict ):
83100 rows = [data ]
84101 for row in rows :
85- for k in ('data ' , 'token_bytes' , 'masking' ):
102+ for k in ('data_str' , 'data_i64' , 'data_i32' , 'email ' , 'token_bytes' , 'masking' ):
86103 row [k ] = row [k ].encode ('ascii' )
87104 connection .execute (
88105 test_table .insert (), row )
0 commit comments