美文网首页
pg 参数问题

pg 参数问题

作者: hehehehe | 来源:发表于2024-07-29 16:47 被阅读0次
    try:
        with db_config.session_resource() as session:

            sql = text("""
                        INSERT INTO test1 (check_id) VALUES (:v1)"
                  """)
            session.execute(sql, {"v1": 's"s'})
    except Exception as e:
        print(e)
        s = str(e)
        # s = s.replace("'", "")
        # s = s.replace('"', "")
        print(s)
        # s = re.sub(r'["\']', '', s)
        print(234, s)
        with db_config.session_resource() as session:
            sql = text("""
                  INSERT INTO test1 (check_id, d) VALUES ('abc',:v1)
            """)
            session.execute(sql, {"v1": json.dumps({"a": s})})
            # sql = f"""
            #       INSERT INTO test1 (check_id, d) VALUES ('a','{json.dumps({"a": s})}')
            # """
            # cursor.execute(sql)
            print(2342)


        with db_config.session_resource() as session:
            sql = text(f"""
                     insert into cmap_qc_log
                        (check_id,task_id,mesh_id,rule_id,rule_version,rule_logic,log_level,log_msg,modify_msg,
                         check_layer,check_field,check_field_val,check_val,id_col_name,id_col_val,create_time,
                         log_type,geom) 
                     values(:check_id,:task_id,:mesh_id,:rule_id,:rule_version,:rule_logic,:log_level,:log_msg,
                        :modify_msg, :check_layer,:check_field,:check_field_val,:check_val,:id_col_name,:id_col_val,
                        :create_time,:log_type,st_geomfromtext(:geom,4326)) 
                     RETURNING id
                 """)
            result = session.execute(sql, log.model_dump())
            return result.fetchone()[0]
with db_util.get_cursor(check_db_cfg) as cursor:
    try:
        sql = """
                    INSERT INTO test1 (check_id) VALUES (%s)"
              """
        cursor.execute(sql, ('s"s',))
    except Exception as e:
        print(e)
        s = str(e)
        # s = s.replace("'", "")
        # s = s.replace('"', "")
        print(s)
        # s = re.sub(r'["\']', '', s)
        print(234, s)
        with db_util.get_cursor(check_db_cfg) as cursor:
            sql = """
                  INSERT INTO test1 (check_id, d) VALUES (%s,%s)
            """
            cursor.execute(sql, ("a", json.dumps({"a": s}),))
            # sql = f"""
            #       INSERT INTO test1 (check_id, d) VALUES ('a','{json.dumps({"a": s})}')
            # """
            # cursor.execute(sql)
            print(2342)


in

with db_util.get_cursor(wdb) as cursor:
    sql = """
           select id,st_astext(geometry) as geometry  
from public."HAD_RDBOUND_LINK" WHERE id  in %s;
        """

    ids = ('227791813806083333', '290095456722557441')
    cursor.execute(sql, (ids,))
    rows = cursor.fetchall()

    for row in rows:
        print(row)
    sql = """
           select id,st_astext(geometry) as geometry  
from public."HAD_RDBOUND_LINK" WHERE id in %s 
        """

    ids = ['227791813806083333', '290095456722557441']
    cursor.execute(sql, (tuple(ids),))
    rows = cursor.fetchall()

    for row in rows:
        print(row)

相关文章

  • 10.参数优先级

    pg参数优先级 pg修改参数方式很多配置文件,alter system,命令行,用户,数据库,所有用户,会话,事务...

  • pg参数优化

    1.shared_buffersPostgreSQL既使用自身的缓冲区,也使用内核缓冲IO。这意味着数据会在内存中...

  • PG 配置参数查看

    1.查看参数文件的位置 使用show 命令查看,比较常用的show config_file.此还可以查看pg_se...

  • PostgreSQL DBA(6) - PG 11 New Fe

    PG 11即将正式发布,本节简单介绍了PG 11的新特性:PL/pgSQL增强和新增的配置参数。 一、PL/pgS...

  • Rails常见问题及解决办法

    No pg_config... 问题重现: 在bundle的时候出现gem包pg-0.18.4安装出错的情况,错误...

  • 第 15 课 PostgreSQL 系统参数配置

    参数文件 postgresql.conf :数据库配置文件 pg_hba.conf : host-based au...

  • 2021-08-14 同步备 ,非同步备

    术语区别 高斯pg同步备同步流复制非同步备异步流复制 同步wal流程图 关键控制参数 参数名作用synchrono...

  • Get PG configuration path

    问题 在osx上装了pg,可以正常运行,但是不知道配置文件在哪 解决 连上pg后,运行 show hba_file;

  • 解决Ceph ERROR: unable to open OSD

    问题描述 单节点的ceph环境,周末机房异常断电后,周一来发现环境大量pg不健康(pg down、stale等)、...

  • unset(20.6.3)

    问题描述 unset在pg9的执行结果 unset在pg10的执行结果 原因 unset当记录少的会补null。 ...

网友评论

      本文标题:pg 参数问题

      本文链接:https://www.haomeiwen.com/subject/lqswhjtx.html