How to use the @prisma/sdk/dist/convertCredentials.databaseTypeToConnectorType function in @prisma/sdk

To help you get started, we’ve selected a few @prisma/sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github prisma / prisma2 / cli / introspection / src / commands / Introspect.ts View on Github external
const basedOn =
      !args['--url'] && schemaPath
        ? ` based on datasource defined in ${chalk.underline(path.relative(process.cwd(), schemaPath))}`
        : ''
    log(`Introspecting${basedOn} …`)

    const before = Date.now()
    let introspectionSchema = await engine.introspect(url)
    engine.stop()

    if (introspectionSchema.trim() === '') {
      throw new Error(`Empty introspection result for ${chalk.underline(url)}`)
    }

    const connectorType = databaseTypeToConnectorType(uriToCredentials(url).type)

    const datasourceString = printDatasources([
      {
        config: {},
        connectorType,
        name: 'db',
        url,
      },
    ])

    introspectionSchema = datasourceString + '\n' + introspectionSchema

    debug('introspectionSchema:')
    debug(introspectionSchema)

    try {