python的数据库应用_Python数据库应用

Kindof a poll, kindof curiosity...

What is your favorite python - database combination? I''m looking to

make an app that has a local DB and a server side DB. I''m looking at

python and sqlite local side and sql server side.

Any suggestions????

Darien

解决方案da************@gmail.com wrote:

Kindof a poll, kindof curiosity...

What is your favorite python - database combination? I''m looking to

make an app that has a local DB and a server side DB. I''m looking at

python and sqlite local side and sql server side.

Any suggestions????

Darien http://dabodev.com/

What is your favorite python - database combination? I''m looking to

make an app that has a local DB and a server side DB. I''m looking at

python and sqlite local side and sql server side.

Any suggestions????

I like to use elixir [1] on top of sqlalchemy [2]

[1] http://elixir.ematia.de/

[2] http://www.sqlalchemy.org/

On Sep 10, 2007, at 10:52 PM, da************@gmail.com wrote:

Kindof a poll, kindof curiosity...

What is your favorite python - database combination? I''m looking to

make an app that has a local DB and a server side DB. I''m looking at

python and sqlite local side and sql server side.

Are you asking for opinions on what sort of database engine to use?

Or are you trying to get a feel for what people use to develop their

apps? Are you looking for a web app, or a desktop app, or a non-UI app?

-- Ed Leafe

-- http://leafe.com

-- http://dabodev.com

使用Python可以轻松地从Oracle数据库中读取数据并生成报表。以下是一些常用的Python库和步骤: 1. 安装必要的Python库:cx_Oracle、pandas、openpyxl等。 2. 连接到Oracle数据库,可以使用cx_Oracle库连接到Oracle数据库。 3. 通过SQL查询从Oracle数据库中获取数据,使用pandas库可以将查询结果转换为DataFrame对象。 4. 使用openpyxl等库将数据入Excel文件中。 以下是一个示例代码,用于从Oracle数据库中获取数据并将其入Excel文件中: ```python import cx_Oracle import pandas as pd from openpyxl import Workbook # 连接Oracle数据库 conn = cx_Oracle.connect('username/password@host:port/service_name') # SQL查询语句 sql = 'SELECT * FROM table_name' # 获取查询结果并转换为DataFrame对象 df = pd.read_sql(sql, conn) # 创建Excel文件 wb = Workbook() # 选择第一个工作表 ws = wb.active # 将DataFrame对象入Excel文件中 for r in dataframe_to_rows(df, index=False, header=True): ws.append(r) # 保存Excel文件 wb.save('report.xlsx') # 关闭数据库连接 conn.close() ``` 以上代码中,需要替换的部分包括: - `username`和`password`:Oracle数据库的用户名和密码 - `host`:Oracle数据库的主机名或IP地址 - `port`:Oracle数据库的端口号 - `service_name`:Oracle数据库的服务名称 - `table_name`:需要查询的表名 - `report.xlsx`:生成的Excel文件名 当然,如果你需要生成其他格式的报表,可以使用不同的Python库来实现。例如,使用matplotlib库可以生成图表,使用reportlab库可以生成PDF报表等。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值