Can not make generateChangeLog working in liquibase to export data from existing database - sqlite

I read some similar questions, but I still can not figure out how to export data or schemas from an exiting database using liquibase. The database i am using is sqlite, and I always got problem.
java -jar liquibase-1.9.3.jar --driver=org.sqlite.JDBC --classpath=lib/sqlite-jdbc-3.7.2.jar --changeLogFile=test.data --url=jdbc:sqlite:test.db --diffTypes="data" generateChangeLog
the error is: Migration Failed: no such column: 'DECIMAL_POINTS'
I just have a testing table with 2 fields: ID (integer type), and name (VARCHAR type).
Can somebody help? Thanks.

I couldn't find more examples about using liquibase with sqlite database. So, I tested and figured out by myself, and commented below:
You need to pick up right jdbc engine for liquibase, when I changed sqlitejdbc engine from sqlite-jdbc-3.7.2.jar to sqlitejdbc-v056.jar (http://www.zentus.com/sqlitejdbc/), it works. So it is important to pick up right one.

Related

SQLite Importer will overwrite my database when I load my application?

I have an Ionic App using SQLite. I don't have any problems with implementation.
The issue is that I need to import an SQL file using SQLitePorter to populate the database with configuration info.
But also, on the same database I have user info, so my question is:
Everytime I start the app, it will import the sql file, fill the database and probably overwrite my user data too? Since it is all on the same base?
I assume that you can always init your table using string queries inside your code. The problem is not that you are importing a .sql file. Right?
According to https://www.sqlitetutorial.net/sqlite-create-table/ it is obvious that you always create a table with [IF NOT EXISTS] switch. Writing a query like :
CREATE TABLE [IF NOT EXISTS] [schema_name].table_name (
column_1 data_type PRIMARY KEY);
you let sqlite to decide if it's going to create a table with the risk to overwrite an existing table. It is supposed that you can trust that sqlite is smart enough, not to overwrite any information especially if you use 'BEGIN TRANSACTION' - 'COMMIT' procedure.
I give my answer assuming that you have imported data and user data in distinct tables, so you can manipulate what you populate and what you don't. Is that right?
What I usually do, is to have a sql file like this:
DROP TABLE configutation_a;
DROP TABLE configutation_b;
CREATE TABLE configutation_a;
INSERT INTO configutation_a (...);
CREATE TABLE configutation_b;
INSERT INTO configutation_b (...);
CREATE TABLE IF NOT EXIST user_data (...);
This means that every time the app starts, I am updating with the configuration data I have at that time (that's is why we use http.get to get any configuration file from a remote repo in the future) and create user data only if user_data table is not there (hopefully initial start).
Conclusion: It's always a good practice, in my opinion, to trust a database product 100% and abstractly let it do any transaction that might give you some risk if you implemented your self in your code; since it gives a tool for that.For example, the keyword [if not exists], is always safer than implementing a table checker your self.
I hope that helps.
PS: In case you refer in create database procedure, SQLite, connects to a database file and it doesn't exist, it creates it. For someone comfortable in sqlite command line, when you type
sqlite3 /home/user/db/configuration.db will connect you with this db and if the file is not there, it will create it.

Referenced table is not in dictionary

When I scaffold my database get the following error:
Referenced table `contentcategory` is not in dictionary.
Referenced table `contentcategory` is not in dictionary.
Referenced table `contenttype` is not in dictionary.
Referenced table `content` is not in dictionary.
I Use Mysql and Pomelo.EntityFrameworkCore.MySql
This is very likely to be a casing issue, where MySQL assumes the table name to be contentcategory for the reference, while it is actually something like ContentCategory.
We have a pull request for this open since April, that looks abandoned by the original contributor.
I will fix the PR and merge it, so that the workaround for this issue will be part of our nightly builds as of tomorrow.
The linked PR also contains the information of how this issue can arise:
Okay, that is in line with what I experienced as well. So manually (either by writing the name in the GUI or by using an ALTER TABLE statement directly) adding a reference with different casing (on a server with case insensitive file name handling) or disabling SQL Identifiers are Case Sensitive [in MySQL Workbench] can lead to this result.
Technically, this is a MySQL or Workbench bug, but we will implement a workaround for it anyway.

Laravel - PHP Artisan Tinker: How to view all tables in sqlite database

I have a Laravel project and I have a sqlite database. I want to view all the tables in the database in php artisan tinker.
I have tried this $tables = DB::select('SHOW TABLES'); but it throws this error Illuminate\Database\QueryException with message 'SQLSTATE[HY000]: General error: 1 near "SHOW": syntax error (SQL: SHOW TABLES)'
Here is the answer, and it can be found here, https://www.sqlite.org/faq.html#q7
DB::select("SELECT name FROM sqlite_master WHERE type='table' ORDER BY name;")
Thanks to #GwynBleidd on Laracasts for finding the answer.
I know that is a old question but i was looking for this, and found a different solution if someone else need, according to Laravel syntax, here it is::
DB::table('sqlite_master')->select('name')->where('type', 'table')->orderBy('name')->get()
This way you can perform a query search, or if you want you can return a Collection array with a list of the name of tables.
$this->DB
->table('sqlite_master')
->select('name')
->where('type', 'table')
->orderBy('name')
->get()
->pluck('name');

How to generate data model diagram from Oracle sql developer

I want to generate a data model diagram from an existing oracle database.
I've tried to use SQL Developer 3.2.20.09 and followed the steps in another post and the demonstration of oracle.
But I didn't succeed. It's a little strange because I can see all the other types of objects except tables.
Here is my steps:
File -> Data Modeler -> Import -> Data Dictionary -> current database connection -> Next -> Current Schema -> Next
Do you have any idea?
Thanks in advance.
EDIT:
I think it's a specific problem in my database. I can't figure it out with SQL Developer.
Finally, I've used TOAD Data Modeler to generate E/R diagram.
As there are not solutions proposed by others, I'll mark my "solution" as answer.
I think it's a specific problem in my database.
I can't figure it out with SQL Developer. Finally, I've used TOAD Data Modeler to generate E/R diagram.
Here's what we're running to get a list of tables in version 4.1 of SQL Developer Data Modeler:
SELECT TABLE_NAME, TABLE_TYPE, TABLE_TYPE_OWNER
FROM dba_all_tables a
WHERE IOT_NAME IS NULL
AND (IOT_TYPE IS NULL
OR IOT_TYPE = 'IOT')
AND NESTED ='NO'
AND a.OWNER =?
AND SECONDARY ='N'
AND NOT EXISTS
(SELECT 1
FROM dba_queue_tables c
WHERE OWNER =?
AND c.QUEUE_TABLE = a.TABLE_NAME
)
ORDER BY TABLE_NAME
Does your connection have access to the DBA_ views?
If we don't see access to the DBA_ views, we drop down to the ALL_ views.
You can follow this tutorial
https://www.youtube.com/watch?v=bpKJmCoBy2c.
I suggest another approach for more convenience: You can drag and drop table from connection into relational screen to generate model and follow the step in the above tutorial for creating diagram.
Hope this help :)

Temp tables are created by default in sqlite

I have created a database "MyDB.sqlite" using the command line sqlite3 MyDB.sqlite in a specific folder(my desktop) and then created a table "tbl11" using create table syntax. I am able to insert record and can check the inserted records.
But when I exit command (terminal in Mac) line and re enter I can't see my database and tables in that folder. I guess this database and table are temporary by default. I even check the .databases command to see the database, but I can only see two database main!
please help!
Be sure to finish off with COMMIT; :-)
For practice, work through the short working example at http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html
Good luck.

Resources