help - Mailing list pgsql-bugs

From XM
Subject help
Date
Msg-id 639e1dcf.48ee.160a044f47a.Coremail.talkcc@163.com
Whole thread Raw
List pgsql-bugs
Hello
        I use Dateframe to_sql to write records to a  postgresql DB 9.6  , It can create the table 'Test_stock_basic_Info_2'  ,but the records cannot be wrote into the table  'Test_stock_basic_Info_2' 

        the following  is the code  , is there  any errors of the code ???   

       thanks for your help .


def testSQL():
    import psycopg2
    import pandas as pd
    from sqlalchemy import create_engine  
    
    try:    
        engine =  create_engine('postgresql+psycopg2://pub:pub@localhost/Wind_Quote') 
        
        #conn=engine.raw_connection()
        
        #cur = conn.cursor()
    
        df = pd.DataFrame()
       
        df['stock_code']='0000' 
        df['ipo_date']    ='2015-01-07' 
        df['sec_name'] ='11111111'
        df['trade_code']  ='22222222222'   
       
       
        try :
            df.to_sql(name='Test_stock_basic_Info_2', con=engine,if_exists='replace',index=False)       
            #conn.commit()   
            #cur.execute('COMMIT')
        except Exception as e:
            print ( time.strftime('At [%Y-%m-%d %H:%M:%S]', time.localtime(time.time())),": index_data: Exception :" , (e) )
            
    except Exception as e:
        print ( time.strftime('At [%Y-%m-%d %H:%M:%S]', time.localtime(time.time())),": program: Exception :" , (e) )
     

    print('Finished  ...')


 



 

pgsql-bugs by date:

Previous
From: Logan Owen
Date:
Subject: Re: Server postgres_fdw "fetch_size" option cannot be updated
Next
From: Jeevan Chalke
Date:
Subject: Re: [BUGS] BUG #14890: Error grouping by same column twice using FDW