python - The shorter code to insert data from Python into Oracle
问题描述
I need to insert data from Python into Oracle. My table in Oracle has about 30 columns. I would like to know if there is a way to use the shorter code in next 3 cases.
case 1
Only 30 columns in my_table
and 30 values in data
cur = con.cursor()
cur.executemany('''
insert into my_table
values (:1,:2,...,:30)
''', data)
con.commit()
cur.close()
case 2
30 columns + 1 column with default sysdate
in my_table
and 30 values in data
cur = con.cursor()
cur.executemany('''
insert into my_table
(col1, col2,..., col30)
values (:1,:2,...,:30)
''', data)
con.commit()
cur.close()
case 3
30 columns in my_table
and 10 values in data
cur = con.cursor()
cur.executemany('''
insert into my_table
(col1, col2,..., col10)
values (:1,:2,...,:10)
''', data)
con.commit()
cur.close()
Is there a way not to list all 30 columns?
Something like values(:)
for case 1 or values(:1 - :10)
for case 3
How can I specify all columns except default sysdate
in case 2?
解决方案
推荐阅读
- c# - 如何在 ASP.NET MVC Web 应用程序中使用 HttpContent 处理并发(状态 409)错误?
- java - eclipse中没有外部档案
- javascript - 在反应中将对象数组嵌套到可下载的 CSV
- laravel - 在 laravel 中通过 slug 显示数据时找不到 404
- c# - Xamarin Shell 层次结构与子页面
- javascript - 如何在文本周围添加一个小框?
- python - 从python中的url读取.odt文件
- python - Python用多维列表创建字典
- google-cloud-platform - 谷歌云防火墙:端口被阻止
- reactjs - 当我将运行 react-js 项目时,npm start 命令不起作用