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.
Related
I have a project that is an ASP.NET Core Web API using Entity Framework Core.
A few time ago I created the database using code-first approach with the necessary migrations.
Now I want run the project in other machine and I get the error when I try for example an post to one endpoint:
Microsoft.Data.SqlClient.SqlException (0x80131904): Cannot open database "MyDatabase" requested by the login. The login failed.
However I think the problem (and I checked with ssms) is that the database doesn't exist.
My connection string, in DbContext is:
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(#"Server=(localdb)\mssqllocaldb;Database=MyDatabase;Trusted_Connection=True;");
}
What is the best way to recreate the database on this machine?
Thanks
Remove
;Database=MyDatabase
From the connection string.
Then you can create the dtaabase
CREATE DaTABASE MyDatabase
After the command has run
USE MyDatabase
so that you can create tables and run sql commands on it.
This will wrk on any database.
You should check prior to the creation if the database exists, bu that is highly depending on the rdms that you are using
I have hosting account in plesk panel. I can create and remove a database in hosting panel.
Now I want to create a database from my local computer using add-migration in code first approach. but the following error occurs:
"login failed for the user [myUserId]"
The connection string in appsettings.json is:
"CourseConnection": "Data Source = host-ip,1433; Initial Catalog=mydb;User ID=myuserid;Password=mypassword"
There are two options to create databases on hosting panel:
localhost:3306(default for mysql)
localhost(default for MS sql v13.0...)
I think that provider name is not mentioned in connectionstring but appsettings.json works fine on my local machine without provider name: System.Data.SqlClient.
after hours of try and error , the problem solved as follows:
i created the database in plesk panel and created a new user .
then assign that user to the database . then in package-manager-console applied update-database command to apply migration that was already added.
i used the same connection string in appsettings.json ,it worked successfully.all table created and migration applied .
it may be helpful for someone.
regards
I'm new to Play framework. I'm trying to configure MySQL database as a datasource to be used with Play.
i have done following setting to connect mysql database to play..
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/phpmyadmin/index.php?db=formdemo&token=3882f545563c7df106e1daf21515e1b7#PMAURL:db=formdemo&server=1&target=db_structure.php&token=3882f545563c7df106e1daf21515e1b7"
but i am getting following configuration error.
play.api.Configuration$$anon$1: Configuration error[Cannot connect to
database [default]]
I am not able to connect my wamp localhost database to play.
How do I modify the configuration file to use a mysql database as opposed to an in-memory version. Do I need to setup an entirely separate DB or can I modify the db.default.url property?
I'm using Play! 2.1.
I have resolved with issue. Thank You for your guidance.
Few lines to Put.
dependency
"mysql" % "mysql-connector-java" % "5.1.18"
Conf
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/FORMDEMO?characterEncoding=UTF-8"
db.default.user=root
db.default.password=""
Follow the reference,
http://blog.knoldus.com/2013/01/28/play-framework-2-0-connectivity-with-mysql-in-scala/
Your url should be in this structure:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="mysql://username:password#localhost/formdemo"
If you didn't set the default password, it is usually root with no password, like this:
db.default.url="mysql://username:#localhost/formdemo"
I have created a local db using SQLEXPRESS through Visual Basic.
I intend to use LINQ to connect to the database from the application. Here is my statement to initially connect to the database:
Dim db As New DataContext("Data Source=localhost\SQLEXPRESS; Initial Catalog=master; Integrated Security=True;")
Ideally, my database would be entered for Initial Catalog, but that was giving me authentication errors for some reason. Now that this statement executes, my next step is to connect to my specific database. However, when I try to connect with a statement like this:
Dim TestCommand = db.ExecuteCommand("Use MyDB.mdf")
I get an error that the database does not exist.
When I query my database with the following commands:
SELECT name FROM master.sys.databases
The returned values are master, tempdb, model, msdb, and C:USERS\MY NAME\DOCUMENTS\MyDB.mdf
I have tried the above "TestCommand" writing out the directory for the database, but I get an error at "C:".
So, my db exists, but can someone explain to me the syntax I should use to "USE" my database?
You should not use the use command this way! You must connect to the application's database directly by setting it as Initial Catalog. If you're not authorized to do so, a use command won't let you either, by the way. So you have to fix the authorization for the database: create a login for your windows account in Sql Server Management Studio and grant it read/write access to the application's database.
I would like to manage my Heroku database with pgadmin client. By now, I've been doing this with psql.
When I use data from heroku pg:credentials to connect de DB using pgadmin, I obtain:
An error has occurred:
Error connecting to the server: FATAL: permission denied for database
"postgres" DETAIL: User does not have CONNECT privilege.
How to achieve the connection?
Open the "Properties" of the Heroku server in pgAdminIII and change the "Maintenance DB" value to be the name of the database you want to connect to.
The default setup is suitable for DBAs et al who can connect to any database on the server, but apparently that isn't true in your case.
After you change the Maintenance DB name as suggested by araqnid's answer above, you should also add your database to the DB restrictions field because without this you will see thousands of databases and you may not be able to find yours in the list if the list is too long.
More details here - How to hide databases that I am not allowed to access
This is for pgAdmin 4
In order to connect pgAdmin to your database (postgres instance in Heroku), do the following:
Login to Heroku, and select the application in which you have the database
Select the Resources tab and then click on "Heroku Postgres Ad-on" (see below). This will open up a new tab.
Select the Settings tab and then click on "View Credentials..." (see below)
You will get the following information that you will use in pgAdmin:
Go to pgAdmin, and create a new server
In the General tab, give a useful name
In the Connection tab, fill the info you got at Heroku
In order to avoid seeing thousands of databases, you need to add your database name to DB restriction in the Advanced tab (see below)
We require SSL for connections outside Heroku. Please verify whether you're forcing SSL in your client.
Answered more thoroughly here: Connecting pgAdmin3 to Postgres on Heroku
We don't allow connections to the postgres database, so be sure to set Maintenance DB to your database name, and be sure to use SSL.
Change the Maintenance Database to the name of your Database, e.g. dva70000p0090. This should work.
the db password local isnt the same db password heroku. please check the heroku ip postgtres address and extrac