如何在不使用熊猫的情况下实施自然加入

发布于 2025-01-24 19:05:09 字数 77 浏览 4 评论 0原文

  • 应使用单个功能

    完成
  • 不应使用熊猫或合并函数或任何其他内置数据库库

  • Should be done using single function

  • Shouldn't use Pandas or merge function or any other inbuilt database libraries

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吐个泡泡 2025-01-31 19:05:09

您可以使用诸如psycopg2之类的本机驱动程序进行postgres https:> https://www.psycopg.org/docs/usage/usage/usage .html

import psycopg2

# Connect to an existing database
conn = psycopg2.connect("dbname=test user=postgres")
cur = conn.cursor()



# Query the database and obtain data as Python objects
cur.execute("""
SELECT * FROM test t
left join test1 t1 on (t.t1_id = t1.id);
""")
fetched_rows = cur.fetchall()


# Make the changes to the database persistent
conn.commit()

# Close communication with the database
cur.close()
conn.close()

You can use native driver like psycopg2 for postgres https://www.psycopg.org/docs/usage.html

import psycopg2

# Connect to an existing database
conn = psycopg2.connect("dbname=test user=postgres")
cur = conn.cursor()



# Query the database and obtain data as Python objects
cur.execute("""
SELECT * FROM test t
left join test1 t1 on (t.t1_id = t1.id);
""")
fetched_rows = cur.fetchall()


# Make the changes to the database persistent
conn.commit()

# Close communication with the database
cur.close()
conn.close()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文