postgres之使用python连接并操作
取一万个随机数,插入数据库
import random
import psycopg2
import string conn=psycopg2.connect(database='postgres',user='postgres',password='postgres',host='192.168.137.3')
cur=conn.cursor() # print(ran_str,type(ran_str)) for i in range(10000):
ran_str = ''.join(random.sample(string.ascii_letters + string.digits, 8)) #生成8位的随机数,包含大小写字母和数字
ran_str = ran_str + '@lenovo.com'
# cur.execute("insert into test8 values(pgp_sym_encrypt('%s','abc','cipher-algo=aes256, compress-algo=0, compress-level=9'))"%(ran_str))
cur.execute("insert into test10 values(encrypt('%s','aa@ghilkjds*dfjMTR','aes-128'))" %(ran_str))
conn.commit() cur.close()
conn.close()
postgres之使用python连接并操作的更多相关文章
- python连接mysql操作(1)
python连接mysql操作(1) import pymysql import pymysql.cursors # 连接数据库 connect = pymysql.Connect( host='10 ...
- python连接,操作 InfluxDB
准备工作 启动服务器 执行如下命令: service influxdb start 示例如下: [root@localhost ~]# service influxdb start Starting ...
- Python连接MongoDB操作
1.安装PyMongo 注意:请勿安装“bson”软件包. PyMongo配有自己的bson包; 执行“pip install bson”或“easy_install bson”则会安装与PyMong ...
- Python 连接、操作数据库
使用python3+pymysql 一.安装python3 a) 从网上下载安装吧 二.安装pymysql https://pypi.python.org/pypi/PyMySQL h ...
- MongoDB聚合查询及Python连接MongoDB操作
今日内容概要 聚合查询 Python操作MongoDB 第三方可视化视图工具 今日内容详细 聚合查询 Python操作MongoDB 数据准备 from pymongo import MongoCli ...
- 随笔记:如何使用Python连接(/操作)Oracle数据库(Windows平台下)
遇到需求,我们需要用Python对Oracle数据库进行操作. 这次我们使用cx_Oracle Oracle Client 在安装cx_Oracle之前,先安装Oracle客户端. cx_Oracle ...
- Python连接ORACLE操作
一.准备工作 1.安装cx_Oracle ttps://pypi.python.org/pypi下查找cx_Oracle并下载 执行安装命令 pip install cx_Oracle-6.0rc1- ...
- Python 如何连接并操作 Aws 上 PB 级云数据仓库 Redshift
Python 如何连接并操作 Aws 上 PB 级云数据仓库 Redshift 一.简介 Amazon Redshift 是一个快速.可扩展的数据仓库,可以简单.经济高效地分析数据仓库和数据湖中的所有 ...
- python连接postgres方法
Python使用PyGreSQL操作PostgreSQL: import pg def operate_postgre_tbl_product(): try: #db = pg.connect(dbn ...
随机推荐
- 安装electron-react-boilerplate遇到的问题
一.yarn安装缓慢 // 查看下载源 yarn config get registry // 修改下载源 yarn config set registry https://registry.npm. ...
- 一张图理解"Figure", "Axes", "Axis"
Figure is the object with the highest level in the hierarchy. It corresponds to the entire graphical ...
- bootstrap响应式布局原理
百分比布局+媒体查询 首先通过媒体查询确认container的宽度,每个col-xx-xx都是通过百分比定义的,屏幕尺寸变化了,container就变化了,col自然就变了 Bootstrap的官方解 ...
- Codechef BINOMSUM
题意:(复制sunset的)有\(T\)天,每天有\(K\)个小时,第\(i\)天有\(D+i−1\)道菜,第一个小时你选择\(L\)道菜吃,接下来每个小时你可以选择吃一道菜或者选择\(A\)个活动中 ...
- LOJ 2980 「THUSCH 2017」大魔法师——线段树
题目:https://loj.ac/problem/2980 线段树维护矩阵. 然后是 30 分.似乎是被卡常了?…… #include<cstdio> #include<cstri ...
- MISC_刷题笔记
图片隐写 png类型 查看文件头文件尾,更改长宽(bugku_隐写) zip类型 压缩包的多层嵌套,用strings看打印出来的是不是一个目录的样子(bugku_眼见非实)
- ffmpeg+nginx-rtmp-module
原址: https://www.cnblogs.com/cnsanshao/p/6370938.html另外: vlc播放器能播放rtsp协议 nginx安装和配置 模块下载 https://gith ...
- [CSP-S模拟测试]:Miner(欧拉路)
题目背景 $And\ the\ universe\ said\ you\ are\ the\ daylight \\ And\ the\ universe\ said\ you\ are\ the\ ...
- 【c#技术】一篇文章搞掂:Newtonsoft.Json Json.Net
一.介绍 Json.Net是一个.Net高性能框架. 特点和好处: 1.为.Net对象和JSON之间的转换提供灵活的Json序列化器: 2.为阅读和书写JSON提供LINQ to JSON: 3.高性 ...
- Linux二进制程序安装使用
下载好的二进制,压缩包解压,或者直接是二进制. 放到想要的目录 在 /etc/environment 双引号前面添加程序路径 以:开头,\结尾可以换行 接下来修改sudo ,不然sudo会找不到 以下 ...