How Python exports Sybase database table records under Linux

Source: Internet
Author: User
Tags sybase sybase database

How to export Sybase database table records

1 Execute the Start Sybase database command
Code:

Dbeng7 GKDB

2 Executing the Connect Sybase database command
Code:

Dbisql-c "uid=dba111;pwd=222sql;eng=gk333db"-Q oilvouch.sql

3 Execute SQL script file Oilvouch.sql export file Oilvouch.txt
Code

Select Top Ten * from Oilvouch;
Output To/root/oilvouch.txt format ASCII;
Commit

---------------------------------------------
The shell is as follows:


Dbeng7 GKDB
Dbisql-c "uid=dba111;pwd=222sql;eng=gk333db"-Q oilvouch.sql

==============================================
The SQL changes are as follows:
Select Top Ten Ttc,cardno,machineoilno,oilno,takedate,oilgunno,
Openo,liter,price,amount,balance,pumpno,paymode,payunit,accountdate,tracode,
Getttime,teamvouchno,transflag,billstatus from Oilvouch ORDER BY takedate Desc

===============================================

Final System implementation:

1 Oildata_vouch.sql

Select top * from Oilvouch order by takedate Desc;
Output To/root/oilvouch.txt format ASCII;
Commit

2 Oildata_export
Dbisql-c "UID=DBA;PWD=SQL;ENG=GKDB"-Q oildata_vouch.sql
MV Oilvouch.txt/opt/vouchoil.txt

3 oildata_py
#! /user/bin/env python
#coding =utf-8
Import Time,os,sched,shutil
Schedule=sched.scheduler (Time.time,time.sleep)
def perform_command (cmd,inc):
Schedule.enter (Inc,0,perform_command, (Cmd,inc))
Os.system (CMD)
def timming_exe (cmd,inc=60):
Schedule.enter (Inc,0,perform_command, (Cmd,inc))
Schedule.run ()
Print ("EXE run.. Shell after ten senconds ")
#result =os.popen ("Dbeng7 gkdb")
Result=os.popen ("Dbeng7/smc20/database/gkdb.db")
Print (Result)
Timming_exe ("./oildata_export", 10)
#shutil. Copy ("Oilvouch.txt", "/opt/oilvouch.txt")

How does Python export Sybase database table records under Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.