取一万个随机数,插入数据库

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连接并操作的更多相关文章

  1. python连接mysql操作(1)

    python连接mysql操作(1) import pymysql import pymysql.cursors # 连接数据库 connect = pymysql.Connect( host='10 ...

  2. python连接,操作 InfluxDB

    准备工作 启动服务器 执行如下命令: service influxdb start 示例如下: [root@localhost ~]# service influxdb start Starting ...

  3. Python连接MongoDB操作

    1.安装PyMongo 注意:请勿安装“bson”软件包. PyMongo配有自己的bson包; 执行“pip install bson”或“easy_install bson”则会安装与PyMong ...

  4. Python 连接、操作数据库

    使用python3+pymysql 一.安装python3 a)         从网上下载安装吧 二.安装pymysql https://pypi.python.org/pypi/PyMySQL h ...

  5. MongoDB聚合查询及Python连接MongoDB操作

    今日内容概要 聚合查询 Python操作MongoDB 第三方可视化视图工具 今日内容详细 聚合查询 Python操作MongoDB 数据准备 from pymongo import MongoCli ...

  6. 随笔记:如何使用Python连接(/操作)Oracle数据库(Windows平台下)

    遇到需求,我们需要用Python对Oracle数据库进行操作. 这次我们使用cx_Oracle Oracle Client 在安装cx_Oracle之前,先安装Oracle客户端. cx_Oracle ...

  7. Python连接ORACLE操作

    一.准备工作 1.安装cx_Oracle ttps://pypi.python.org/pypi下查找cx_Oracle并下载 执行安装命令 pip install cx_Oracle-6.0rc1- ...

  8. Python 如何连接并操作 Aws 上 PB 级云数据仓库 Redshift

    Python 如何连接并操作 Aws 上 PB 级云数据仓库 Redshift 一.简介 Amazon Redshift 是一个快速.可扩展的数据仓库,可以简单.经济高效地分析数据仓库和数据湖中的所有 ...

  9. python连接postgres方法

    Python使用PyGreSQL操作PostgreSQL: import pg def operate_postgre_tbl_product(): try: #db = pg.connect(dbn ...

随机推荐

  1. The main Method

    The main Method You can call static methods without having any objects. For example, you never const ...

  2. iis7反向代理

    很多站长通常在Linux系统下使用nginx作为前端server,通过反向代理间接访问其他webserver.那么如果用户安装的是Windows系统的话,又改如何实现反向代理的设置呢?搜索引擎大全 下 ...

  3. UVA 12012 Detection of Extraterrestrial(KMP求循环节)

    题目描述 E.T. Inc. employs Maryanna as alien signal researcher. To identify possible alien signals and b ...

  4. Linux配置postfix

    启动报错:主机名不能以数字开头,否则报错

  5. LOJ 6436 「PKUSC2018」神仙的游戏——思路+卷积

    题目:https://loj.ac/problem/6436 看题解才会. 有长为 i 的 border ,就是有长为 n-i 的循环节. 考虑如果 x 位置上是 0 . y 位置上是 1 ,那么长度 ...

  6. 7.zabbix常用item

    zabbix常用item zabbix常用item vfs.file.md5sum[/etc/crontab] {basic:vfs.file.md5sum[/etc/crontab].diff()} ...

  7. 转载:解决npm安装时出现run `npm audit fix` to fix them, or `npm audit` for details

    转载自:https://blog.csdn.net/qq_39165556/article/details/89333028 1.第一种解决办法 npm audit fix npm audit fix ...

  8. python数据分析中常用的库

    Python是数据处理常用工具,可以处理数量级从几K至几T不等的数据,具有较高的开发效率和可维护性,还具有较强的通用性和跨平台性,这里就为大家分享几个不错的数据分析工具,需要的朋友可以参考下 Pyth ...

  9. phpstorm中sass编译时目录或内容包含中文字符报错

    ruby版本:ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32] sass版本:Sass 3.4.24 (Selective Steve) ...

  10. SharePoint 2013中PerformancePoint仪表板设计器连接Analysis Services 2012的问题

    在SharePoint 2013的PerformancePoint仪表板设计器在创建链接到AnalysisServices 2012的数据链接的时候,数据库列表无法获取服务器上的数据库.这个问题挺让人 ...