Skip to content

Instantly share code, notes, and snippets.

@colemanja91
Last active February 10, 2023 13:47
Show Gist options
  • Save colemanja91/532a269eaaa09ef9e3c2a8984bf69bb8 to your computer and use it in GitHub Desktop.
Save colemanja91/532a269eaaa09ef9e3c2a8984bf69bb8 to your computer and use it in GitHub Desktop.
Basic pyeloqua import
"""
NOTICE: I no longer support pyeloqua-related code, I have not worked in Eloqua since 2017 and the APIs have likely changed since then
Import a small set of contacts to Eloqua
"""
from os import environ
from pyeloqua import Bulk
# Initialize Bulk object
# Here I pass environment variables which contain the necessary information
# You could also pass strings with username, password, and company
bulk = Bulk(company=environ['ELOQUA_COMPANY'],
username=environ['ELOQUA_USER'],
password=environ['ELOQUA_PASSWORD'])
# define what action we are taking (import) and what object we are importing to (contacts)
bulk.imports('contacts')
# define which fields we are importing
bulk.add_fields(['C_EmailAddress', 'C_FirstName'])
# define an identifier field which Eloqua will match on for upsert
bulk.add_options(identifierFieldName='C_EmailAddress')
# define a sample set of data to import
data = [
{
'C_EmailAddress': 'example1@test.com',
'C_FirstName': 'tester'
},
{
'C_EmailAddress': 'example2@test.com',
'C_FirstName': 'testing'
}]
# Initialize the import
bulk.create_def('test_import')
# send import data
bulk.post_data(data)
# initialize data sync
bulk.sync()
# output will be status of sync
@Myself1214
Copy link

I find this helpful, given the fact that there is hardly any example of pyeloqua module's use over the internet. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment