ChatGPT Personalized Content

Uploaded on July 2, 2023

I use ChatGPT every time I code. As I ask it more questions about issues I’m running into, I realize it knows my codebase.

All my queries that I submit are through my Open AI account, and it’s clear that ChatGPT is responding to me specifically. I recently asked it this question:

write a python script to go through a mysql table on a remote host and get all the rows in table tags. for each row, write the row to a local table `tags_test'. tags_test has all of `tags` columns, and one more - `image_id`. `tags` has a column `hash` - for each row, try to find a row in the table `images` whose value in column `image_hash` is the same as `tags`.`hash`. If it exists, set the value of `image_id` to the found row in `images` value for `id`. If it doesn't exist, don't write the row to `tags_test`.

The response was:

Certainly! Here's a Python script that connects to a remote MySQL database, retrieves all rows from the "tags" table, and inserts the matching rows into the "tags_test" table in a local database:

import mysql.connector

# Connect to the remote MySQL database
remote_host = 'REMOTE_HOST'
remote_user = 'REMOTE_USER'
remote_password = 'REMOTE_PASSWORD'
remote_database = 'REMOTE_DATABASE'

remote_connection = mysql.connector.connect(
    host=remote_host,
    user=remote_user,
    password=remote_password,
    database=remote_database
)

# Connect to the local MySQL database
local_host = 'LOCAL_HOST'
local_user = 'LOCAL_USER'
local_password = 'LOCAL_PASSWORD'
local_database = 'LOCAL_DATABASE'

local_connection = mysql.connector.connect(
    host=local_host,
    user=local_user,
    password=local_password,
    database=local_database
)

# Create a cursor for the remote database
remote_cursor = remote_connection.cursor(dictionary=True)

# Retrieve all rows from the remote "tags" table
remote_cursor.execute("SELECT * FROM tags")

# Iterate over the rows
for remote_row in remote_cursor:
    # Check if the corresponding image exists in the local "images" table
    local_cursor = local_connection.cursor(dictionary=True)
    local_cursor.execute("SELECT id FROM images WHERE image_hash = %s", (remote_row['hash'],))
    image_row = local_cursor.fetchone()
    local_cursor.close()

    # If a matching image is found, insert the row into the local "tags_test" table
    if image_row is not None:
        local_cursor = local_connection.cursor()
        query = """
            INSERT INTO tags_test (tag_name, tag_type, hash_name, upload_datetime, image_id)
            VALUES (%s, %s, %s, %s, %s)
        """
        local_cursor.execute(query, (
            remote_row['tag_name'],
            remote_row['tag_type'],
            remote_row['hash'],
            remote_row['upload_datetime'],
            image_row['id']
        ))
        local_connection.commit()
        local_cursor.close()

# Close the connections
remote_cursor.close()
remote_connection.close()
local_connection.close()

If you look at the INSERT INTO tags_test line, it accurately knew the schema for my tags_test table. I probably gave it some sort of input that either allowed it to infer this or I maybe pasted a CREATE statement that needed modification, but I don’t remember when I would have done that. It remembered it, long term. That means that if programmers are using this to help with generate code, Open AI is going to be able to map out code bases of competitors/random projects. I wonder if this will ever become an issue for companies.