Closed hongquan closed 1 year ago
Found the solution. I missed this part in tutorial: https://www.edgedb.com/docs/edgeql/parameters#optional-parameters
q = '''
INSERT User {
username := <str>$username,
password := <str>$password,
first_name := <optional str>$firstname,
last_name := <optional str>$lastname,
email := <str>$email,
is_active := <bool>$active,
is_superuser := <bool>$is_superuser,
}
'''
for u in users:
firstname = u.firstname
lastname = u.lastname
r = client.query(q, username=u.username, password=u._password,
firstname=firstname, lastname=lastname,
email=u.email, active=u.active, is_superuser=u.is_superuser)
I'm trying migrating an SQLAlchemy application to EdgeDB. I already define EdgeDB schema and now want to copy data from old PostgreSQL database to EdgeDB. Some value of Postgres column is
NULL
. How to insert empty set to EdgeDB via edgedb.Client.query?For example, my code is:
where
u.firstname
andu.lastname
can beNone
. I tried above code but got this error: