1

我想编写一个 GAE 应用程序,从我的 MSSQL 服务器获取数据,将其转换并存储在 GAEs 云数据库中,并用于其他一些进程。

有没有可能?我找不到任何有关将表单 gae 连接到 mssql 和查询数据的信息。

我找到了Bulk Loader,但认为它对我没有任何用处。而且这个页面也扼杀了我对此的希望,看起来它没有 Windows 支持。

4

1 回答 1

1

I used pyodbc to connect my MSSQL server, using this code lines;

con = pyodbc.connect("DRIVER={SQL Server}; SERVER=my_server_ip; DATABASE=db_name; UID=user_id; PWD=password; CHARSET=UNICODE")
cur = con.cursor()

(First I wrote some more code to convert database tables into CSV files then uploaded them.)

Afterwards I used bulkloader to upload and download from tables. Bulkloader documentation is lack of examples tho. I wrote this code to upload and download via os library that provides dos commands to work in script. Provided CSV files to upload from the file I stored them after conversion.

Upload:

os.system("appcfg.py upload_data --config_file=bulkloader.yaml --log_file=/logs --url=http://my_app_name.appspot.com/_ah/remote_api --kind=kind --filename=CSV_files/table_name.csv --email=my_email_adress)

Download:

os.system("bulkloader.py --download --config_file=bulkloader.yaml --kind=kind --url=http://my_app_name.appspot.com/_ah/remote_api --filename=CSV_files/table_name.csv")
于 2013-09-13T15:44:54.013 回答