class BroadcastMessage(Base, TrackMixin): __tablename__ = 'FBK_BROADCAST_MSG' id = Column(NUMBER, Sequence('FBK_BROADCAST_MSG_SEQ'), primary_key=True, name='ID') message_creative_id = Column(VARCHAR(50), name='MESSAGE_CREATIVE_ID') message_creative_type = Column(VARCHAR(50), name='MESSAGE_CREATIVE_TYPE') is_already_broadcast = Column(VARCHAR(1), name='IS_ALREADY_BROADCAST') content = Column(VARCHAR2(1000), name='CONTENT')
class Broadcast(Base, TrackMixin): __tablename__ = 'FBK_BROADCAST' id = Column(NUMBER, Sequence('FBK_BROADCAST_SEQ'), primary_key=True, name='ID') message_creative_id = Column(VARCHAR(50), name='MESSAGE_CREATIVE_ID') notification_type = Column(VARCHAR(50), name='NOTIFICATION_TYPE') broadcast_id = Column(VARCHAR(50), name='BROADCAST_ID') messaging_type = Column(VARCHAR(50), name='MESSAGING_TYPE') tag = Column(VARCHAR(50), name='TAG')
class FacebookConfig(Base): __tablename__ = 'FBK_CONFIG' id = Column(NUMBER, Sequence('FBK_CONFIG_SEQ'), primary_key=True, name='ID') key = Column(VARCHAR(100), name='KEY') value = Column(VARCHAR(200), name='VALUE') description = Column(VARCHAR(200), name='DESCRIPTION')
def mapping_df_types(df): dtypedict = {} for i, j in zip(df.columns, df.dtypes): if "object" in str(j): dtypedict.update({i: VARCHAR(256)}) if "float" in str(j): dtypedict.update({i: NUMBER(19, 8)}) if "int" in str(j): dtypedict.update({i: VARCHAR(19)}) return dtypedict
def test_column_datatype_to_string(self): test_cases = ( (DATE(), "DATE"), (VARCHAR(length=255), "VARCHAR(255 CHAR)"), (VARCHAR(length=255, collation="utf8"), "VARCHAR(255 CHAR)"), (NVARCHAR(length=128), "NVARCHAR2(128)"), ) for original, expected in test_cases: actual = OracleEngineSpec.column_datatype_to_string( original, oracle.dialect()) self.assertEqual(actual, expected)
class User(Base, TrackMixin): __tablename__ = 'FBK_USER' id = Column(NUMBER, Sequence('FBK_USER_SEQ'), primary_key=True, name='ID') username = Column(VARCHAR(50), unique=True, name='USERNAME') password = Column(VARCHAR(200), name='PASSWORD') full_name = Column(VARCHAR(50), name='FULL_NAME') is_login_ad = Column(VARCHAR(1), name='IS_LOGIN_AD') email = Column(VARCHAR(50), unique=True, name='EMAIL') facebook_id = Column(VARCHAR(50), name='FACEBOOK_ID')
import pandas as pd import pymysql from sqlalchemy import create_engine from sqlalchemy.dialects.oracle import VARCHAR conn = pymysql.connect(user='******', password='', db='compare_test') df_src = pd.read_sql("select * from test_table", conn) con2 = create_engine('mysql+pymysql://root:@localhost/compare_test_copy') # oracle+cx_oracle://user:pass@host:port/dbname cols = df_src.dtypes[df_src.dtypes == 'object'].index type_mapping = {col: VARCHAR(255) for col in cols} df_src.to_sql('inventory', con2, dtype=type_mapping, schema='', index=False, if_exists='replace') # df_src.to_sql('test_target_table', con2, schema='', index=False) # df_src.to_sql('test_target_table', conn2, schema='')