<jupyter_start><jupyter_text>import cx_Oracle cx_Oracle.init_oracle_client(lib_dir=r"C:\oracle\instantclient_18_5")<jupyter_code>from sqlalchemy import Column, Integer, String, DateTime, Float, Sequence,Index, create_engine, TIMESTAMP, DateTime
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine('oracle://SYSTEM:vnpy@localhost:1521/XE', encoding='utf8', echo=True, max_identifier_length=128)
Base = declarative_base()
class DbBarData(Base):
    __tablename__ = 'DbBarData'

    symbol = Column(String(255), primary_key=True)
    exchange = Column(String(255), primary_key=True)
    datetime = Column(DateTime, primary_key=True)
    interval = Column(String(255), primary_key=True)

    volume = Column(Float)
    open_interest = Column(Float)
    open_price = Column(Float)
    high_price = Column(Float)
    low_price = Column(Float)
    close_price = Column(Float)


class DbTickData(Base):
    __tablename__ = 'DbTickData'

    symbol = Column(String(255), primary_key=True)
    exchange = Column(String(255), primary_key=True)
    datetime = Column(TIMESTAMP, primary_key=True)

    name = Column(String(255))
    volume = Column(Float)
    open_interest = Column(Float)
    last_price = Column(Float)
    last_volume = Column(Float)
    limit_up = Column(Float)
    limit_down = Column(Float)

    open_price = Column(Float)
    high_price = Column(Float)
    low_price = Column(Float)
    pre_close = Column(Float)

    bid_price_1 = Column(Float)
    bid_price_2 = Column(Float)
    bid_price_3 = Column(Float)
    bid_price_4 = Column(Float)
    bid_price_5 = Column(Float)

    ask_price_1 = Column(Float)
    ask_price_2 = Column(Float)
    ask_price_3 = Column(Float)
    ask_price_4 = Column(Float)
    ask_price_5 = Column(Float)

    bid_volume_1 = Column(Float)
    bid_volume_2 = Column(Float)
    bid_volume_3 = Column(Float)
    bid_volume_4 = Column(Float)
    bid_volume_5 = Column(Float)

    ask_volume_1 = Column(Float)
    ask_volume_2 = Column(Float)
    ask_volume_3 = Column(Float)
    ask_volume_4 = Column(Float)
    ask_volume_5 = Column(Float)


class DbBarOverview(Base):
    __tablename__ = 'DbBarOverview'

    symbol = Column(String(255), primary_key=True)
    exchange = Column(String(255), primary_key=True)
    interval = Column(String(255), primary_key=True)
    count = Column(Integer)
    start = Column(DateTime)
    end = Column(DateTime)

Base.metadata.create_all(engine)
DbBarData.__table__
DbTickData.__table__.drop(engine)
DbBarData.__table__.drop(engine)
DbBarOverview.__table__.drop(engine)
Database = sessionmaker(bind=engine)
db = Database()
from datetime import datetime
a=datetime.now()
one = DbBarData(symbol='IF888', exchange ='CFFEX', datetime =a, interval = '1h', volume = 0, open_interest =0, open_price = 0, high_price = 10, low_price =0.5, close_price = 0.5)
one = DbBarOverview(symbol='IF888', exchange ='CFFEX', interval = '1m', count=10, start=a,end=a)
db.merge(one)
db.commit()
b=db.query(DbBarData).filter_by(exchange='CFFEX').all()
(b[0].datetime)
count = db.query(DbTickData).filter(
            DbTickData.exchange == 'BINANCE'
        ).delete()

db.commit()
 
for instance in db.query(DbBarData).order_by(DbBarData.datetime):
    print(instance.interval)
db.rollback()
from pytz import utc  
from pytz import timezone  
from datetime import datetime  

cst_tz = timezone('Asia/Shanghai')  
utc_tz = timezone('UTC')  

now = datetime.now().replace(tzinfo=cst_tz)  
now
len(b)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11713237369460909, 'fraction_numerical': 0.02201524132091448, 'mean_word_length': 4.838550247116968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '137316', 'license': 'MIT', 'n_tokens_mistral': 1269, 'n_tokens_neox': 1199, 'n_words': 229, 'path': 'test.ipynb', 'repo_name': 'noranhe/vnpy_oracle', 'size': '3543'}