A MySQL Language Pack for OpenFn
npm install @openfn/language-mysqlLanguage Pack for building expressions and operations to run MySQL queries.
View the docs site for
full technical documentation.
View all the required and optional properties for state.configuration in the
official
configuration-schema
definition.
Execute an sql query with the node mysql package.
``jsselect * from ${state.data.table} where id = ?;
query({
sql: state => {
return ;`
},
timeout: 4000,
values: ['007'],
});
This function takes either a string or a function that takes states and
returns a string.
`jsINSERT INTO untitled_table (name, the_geom) VALUES ('
sqlString(state => {
return (
+',
state.data.version +
+)
dataValue('form.Choix_tache')(state) +
`
);
});
This function is used to insert a single record in a MySQL database.
`js`
insert(
'some_table',
fields(
field('firstname', dataValue('form.patient_firstname')),
field('lastname', dataValue('form.patient_lastname'))
)
);
This function is used to insert a single record in a MySQL database or update it
if there is a match.
`js`
upsert(
'some_table',
fields(
field('firstname', dataValue('form.patient_firstname')),
field('lastname', dataValue('form.patient_lastname'))
)
);
This function allows the upsert of a set of records inside a table all at once.
`js`
upsertMany(
'users', // the DB table
[
{ name: 'one', email: 'one@openfn.org' },
{ name: 'two', email: 'two@openfn.org' },
]
);
or
`js`
upsertMany('users', state =>
state.data.users.map(user => {
name: user['name'],
email: user['email']
})
);
Clone the adaptors monorepo. Follow the
Getting Started guide inside to get set up.
Run tests using pnpm run test or pnpm run test:watch
Build the project using pnpm build.
To just build the docs run pnpm build docs`