How to migrate SQLite database to an encrypted SQLite database? (Titanium) - database

I have an existing app built with appcelerator's titanium. It currently has a database existing on it, but I want to upgrade it to an encrypted database. I am using appcelerator's encrypted database module. If I delete the local database and build the app clean it is fine, the problem is when I try to migrate from the existing database to the encrypted one. I get this error:
file is encrypted or is not a database
message = "Couldn't open database and migrate";
Script Error Module "alloy/models/table.js" failed to leave a valid exports object
My exports definition looks like this:
'config': {
columns: columns,
defaults: {},
adapter: {
"type": "enc.db",
"collection_name": "table",
"idAttribute": "LocalID",
"db_name": "_alloy_.enc.db"
}
},

Related

Prisma SQLServer Connection database was empty

I'm trying to connect to my SqlServer with Prisma. When i try to "prisma db pull" im getting this error.
P4001 The introspected database was empty
Of course my db is not empty. These are my connection string(database, user and password is true) and schema.prisma;
Connection String at .env:
DATABASE_URL="sqlserver://192.168.1.86;database=***_live_IT;user=***;password=***;encrypt=DANGER_PLAINTEXT;"
schema.prisma:
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlserver"
url = env("DATABASE_URL")
}
And here is my SqlServer Tables(i want to connect ***_live_IT)
SQLServer Databases
And here is Tables of that Database
SQLServer Tables
Any idea is appreciated. Thanks in advance.
Edit:
Full text of error here.
PS D:\xampp\htdocs\noip> npx prisma db pull
npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
Prisma schema loaded from prisma\schema.prisma
Environment variables loaded from .env
Datasource "db" - SQL Server
✖ Introspecting based on datasource defined in prisma\schema.prisma
Error:
P4001 The introspected database was empty:
prisma db pull could not create any models in your schema.prisma file and you will not be able to generate Prisma Client with the prisma generate command.
To fix this, you have two options:
- manually create a table in your database.
- make sure the database connection URL inside the datasource block in schema.prisma points to a database that is not empty (it must contain at least one table).
Then you can run prisma db pull again.
adding "schema=<schema_name>" to the database url solved this for me when trying to connect to a local sqlserver. Unfortunately, prisma can only connect to one schema at a time.

PostgresException: 3D000: database "kap_dev" does not exist

I am using serenity with postgres and I have generated a new project using visual studio 2019.
I have followed the tutorial of how to make the app connect with Postgresql.
I have created a new database and user in PgAdmin.
I have enabled the app to run migrations when I run my app.
Here is a sample of my connection string.
"Data": {
"Default": {
"ConnectionString": "Server=localhost; Port=5432; User Id=kap_dev; Database=kap_db; Password=kapap_password;",
"ProviderName": "Npgsql"
}
However, I get the error
PostgresException: 3D000: database "kap_dev" does not exist.
The issue is that kap_dev is a user and not a database.
I even posted this error to their git-issues but serenity have not responded with a valid answer.
might be a typo, no space between User and Id
You have to create a database which name is the name of your user "kap_dev".

Why i can not able to access my rails application db after establishing new connection to wordpress db manually?

I have a rails 4.2 application with postgres database which is running. I have requirement to connect with other databases (word_press_sites) on demand basis.
I have tried the below code this into rails console:
ActiveRecord::Base.establish_connection(
adapter: "mysql2",
host: ENV["HOST"],
username: ENV["USERNAME"],
password: ENV["PASSWORD"],
database: ENV["DB_NAME"]
)
above code results,
No error, connected to the word_press database_tables.
1) If am trying to access the table by calling User.all in my rails application db i can not able to access which is throwing an error.
After opening the rails console you can check
ActiveRecord::Base.connection.current_database
This will give the current db info,Then try the script you have given
ActiveRecord::Base.establish_connection(
adapter: "mysql2",
host: ENV["HOST"],
username: ENV["USERNAME"],
password: ENV["PASSWORD"],
database: ENV["DB_NAME"]
)
Now try the same command
ActiveRecord::Base.connection.current_database
This will give the newly connected ActiveRecord connection
Which means Active record is shifted into newly connected wordpress database so that you can not able to access the table in your rails application database
If you want to revert back to your rails app db you can do this
ActiveRecord::Base.remove_connection( ActiveRecord::Base)
Let me know if you need more information

Azure - Data not showing on Easy Tables

I am using an Azure SQL back-end for my Xamarin mobile application. I am using Easy tables with Node.JS to handle my back-end. I have created a few tables using the easy tables creation wizard, but now I wish to manually migrate some of my old MySQL tables, such as my table named users from another database into my new Azure SQL database.
1) I have used the SqlMigration3 tool to convert the MySQL tables into Azure SQL, changed the schema to be the same as the Easy Table's schema, and they are now in my Azure SQL Database
2) I have created the Node.JS files users.js and users.json in my App Service Editor and now my table is showing in easy tables
users.js
var table = module.exports = require('azure-mobile-apps').table();
// table.read(function (context) {
// return context.execute();
// });
// table.read.use(customMiddleware, table.operation);
users.json
{
"softDelete" : true,
"autoIncrement": false,
"insert": {
"access": "anonymous"
},
"update": {
"access": "anonymous"
},
"delete": {
"access": "anonymous"
},
"read": {
"access": "anonymous"
},
"undelete": {
"access": "anonymous"
}}
The users table is showing up in Easy Tables but there is no data showing, despite the data displaying in SQL Server Management Studio 2017. Have I missed a step? What am I doing wrong?
In my test, I am also unable to see the data from Azure portal when I do the same steps as yours. I think the portal needs time to load the data since it might have many records.
Since you set Read permission to Allow anonymous access, I would recommend accessing the table via REST API:
https://[YourAppName].azurewebsites.net/tables/users?ZUMO-API-VERSION=2.0.0

Merging MVC4 membership database with entity framework code first database

I am using MVC4 with the default membership provider and using entity framework code first. The membership data is in a database stored in my app_data folder called aspnet-xxxxxx.mdf, and my application data is created in a separate database running on SQL Server express.
What do I have to do so that I have 1 database containing my membership tables and the application data? I do not mind losing the data in either of these databases as at the moment it is only test data.
Find your InitializeSimpleMembershipAttribute.cs and change in the line
WebSecurity.InitializeDatabaseConnection("[ConnectionString]", builder.Provider, "UserProfile", "UserId", "UserName", autoCreateTables: false);
[ConnectionString] to your connection string name you defined in Web.config. Or provide a complete connection string

Resources