Skip to content
This repository has been archived by the owner on Oct 10, 2022. It is now read-only.

[oracle] Tables not found in selected database. Skipping creation of typeorm model. #297

Closed
liudonghua123 opened this issue Sep 2, 2020 · 4 comments
Labels

Comments

@liudonghua123
Copy link

I have a remote oracle database, first I run npx typeorm-model-generator and filled some database configurations. And at last I got the following errors.

D:\code\ynu\yx_statistics\server>npx typeorm-model-generator
[email protected]
[3:47:20 PM] Using configuration file. [D:\code\ynu\yx_statistics\server\.tomg-config]
[3:47:20 PM] Starting creation of model classes.
Tables not found in selected database. Skipping creation of typeorm model.
Error occurred in typeorm-model-generator.
[email protected]  [email protected]
If you think this is a bug please open an issue including this log on https://github.com/Kononnable/typeorm-model-generator/issues
[3:47:20 PM] Typeorm model classes created.

I checked the .tomg-config file and the connection part is something like the following.

  {
    "host": "remote_ip",
    "port": 1521,
    "databaseName": "sid_name",
    "user": "xxx",
    "password": "yyy",
    "databaseType": "oracle",
    "schemaName": "",
    "ssl": false,
    "skipTables": []
  }

Notes remote_ip,sid_name,xxx,yyy is some placeholder.

Because the tables I want to generate models is located in another user's tablespace. I tried to modify schemaName to something like USR_ANOTHER.TABLE1,USR_ANOTHER.TABLE2. but it's the same error.

I also tried a write a plain demo and typeorm demo. They all works.
The only important notes is the table name should prefixed with USR_ANOTHER.

demo code

plain oracledb demo

// oracle_test.js
const oracledb = require('oracledb');

async function run() {
  let connection;

  try {
    let sql, binds, options, result;

    connection = await oracledb.getConnection({
      connectString: 'remote_ip/sid_name',
      user: 'xxx',
      password: 'yyy',
    });
    //
    // Query the data
    //

    sql = `SELECT * FROM USR_ANOTHER.TABLE1`;

    binds = {};

    // For a complete list of options see the documentation.
    options = {
      outFormat: oracledb.OUT_FORMAT_OBJECT, // query result format
      // extendedMetaData: true,               // get extra metadata
      // prefetchRows:     100,                // internal buffer allocation size for tuning
      // fetchArraySize:   100                 // internal buffer allocation size for tuning
    };

    result = await connection.execute(sql, binds, options);

    console.log('Metadata: ');
    console.dir(result.metaData, { depth: null });
    console.log('Query results: ');
    console.dir(result.rows, { depth: null });

    //
    // Show the date.  The value of ORA_SDTZ affects the output
    //

    sql = `SELECT TO_CHAR(CURRENT_DATE, 'DD-Mon-YYYY HH24:MI') AS CD FROM DUAL`;
    result = await connection.execute(sql, binds, options);
    console.log('Current date query results: ');
    console.log(result.rows[0]['CD']);
  } catch (err) {
    console.error(err);
  } finally {
    if (connection) {
      try {
        await connection.close();
      } catch (err) {
        console.error(err);
      }
    }
  }
}

run();

typeorm demo

// ormconfig.json

{
   "type": "oracle",
   "host": "remote_ip",
   "username": "xxx",
   "password": "yyy",
   "port": 1521,
   "sid": "sid_name",
   "synchronize": false,
   "logging": false,
   "entities": [
      "src/entity/**/*.ts"
   ],
   "migrations": [
      "src/migration/**/*.ts"
   ],
   "subscribers": [
      "src/subscriber/**/*.ts"
   ],
   "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
   }
}
// entity
import {Entity, PrimaryGeneratedColumn, Column, BaseEntity} from "typeorm";

@Entity({name:'USR_ANOTHER.TABLE1'})
export class TABLE1 extends BaseEntity {
...
}
// index.ts
import "reflect-metadata";
import {createConnection} from "typeorm";
import {TABLE1} from "./entity/TABLE1";

createConnection().then(async connection => {

    console.log("Loading table1 from the database...");
    const data= await TABLE1.find();
    console.log("Loaded data: ", data);

    console.log("Here you can setup and run express/koa/any other framework.");

}).catch(error => console.log(error));
@Kononnable
Copy link
Owner

Could you check the workaround from #112 ? It looks like the same issue.

@stale
Copy link

stale bot commented Nov 6, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Nov 6, 2020
@liudonghua123
Copy link
Author

@Kononnable Hi, I checked the solution from #112, but I still could not find how to get it.

@stale stale bot removed the stale label Nov 6, 2020
@stale
Copy link

stale bot commented Jan 5, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 5, 2021
@stale stale bot closed this as completed Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants