I want to deploy my Symfony5 project on to a remote shared hosting (Hostinger). I've already set up an account on Hostinger and I've also managed to create a database through their database module using "phpMyAdmin".
Now, how can I work with Doctrine if my database is already created and on Hostinger? All the examples I've seen when using Doctrine and Symfony5, create a local database and operate with it. Is it the same steps for a remote database already created?
In my Symfony5 project I've already installed the "symfony/orm-pack" and I've also updated my "DATABASE_URL" on the ".env" file as follows: DATABASE_URL="mysql://u811510647_guillemba:[db_password_hidden_for_obv_reasons]#127.0.0.1:3306/u811510647_containers?serverVersion=10.2"
The parameters of: [db_user, db_password, db_name and serverVersion] are all adapted on what Hostinger's remote database is telling me to enter.
The "symfony console doctrine:database:create" makes no sense if the database is already created no? How can I create an entity on this remote database with Doctrine?
I'd really appreciate some help, thanks a lot!
It sounds like you have an existing database and you want to import the schema to your Symfony project?
php bin/console doctrine:mapping:import "App\Entity" annotation --path=src/Entity
Note: If you want to specify a specific database from your project then you can also pass in the em
--em=myconnectionname
Related
I have created a site that uses MySQL and I want to get it online.
My question is:
What happens with the database that I created?
Will it automatically be saved in the host?
Will all the tables etc. remain the same?
Also, I have created an update module which connects to the database to store new data.
What happens in than case?
If anyone knows details about the whole process.
Please let me know!
Thanks in advance!
If you use local database for development, you need to export database from local database and import them into the database of your hosing provider or any other online database.
If you developed your site using the online database like database provided by the hosting site, there will be data and database as it is.
In your case the database is stored locally. So every change you make during development will be reflected only if your local database is imported to online database.
I have a knex powered app that once I clone from github, I can run yarn migrate:latest to get the database up to date.
The problem is, in some cases, like a new developer, the database might not yet exist.
What is the right way to first create the database? Do I need to do that outside of KNEX or is there a KNEX CLI/Migration type of commend for this need?
Thats not supported (knex 0.14.2). You need to create database + db users in advance. If you like to have node library helping in that knex-db-manager is knex based helper lib for database management like creating DBs and db owner user etc.
I'm having a small issue. I'm trying to install a plugin (http://plugins.cakephp.org/p/720-users), the user management plugin. For this, I need to create some mysql tables, but I guess you need to create these via a php file and the Console of cakephp. The problem is that I have a very simple server that can only run php and a mysql database. Is there a way to create the sql code out of this php file without the console? The file is question is https://github.com/CakeDC/users/blob/master/Confi
No, you can't. Get a less crappy host. I'm paying only $12 for 3 month (!) for my private virtual server with root access.
Alternatively you could run the migration or schema shell locally, dump the tables and insert them via phpmyadmin on your crappy host.
I installed MySQL on an EC2 instance and need to get some information about that database so I can setup pligg on it.
The info it needs are: Database Name, Username, Password, Database Server and Table Prefix. Is there a simple way to retrieve this information? I assume I need to use PuTTy but I couldn't find specific info on it.
Thanks
The database server is most likely to be localhost and the rest are values that you must set. The docs for whatever application you are installing should give a tutorial on how to create these.
You might find phpMyAdmin useful if the application provides a SQL script to run and you don't want to use the command line.
I'm using Django and MySQL to serve a website. I have my own MySQL server on localhost for my site. Now I have a third-party MySQL database that I need to use to read and write to that is on a remote host. I set up the new database's information in my settings.py file, but a problem occurs when I try to access the remote DB. Because the new DB is not created by me, I have no respective classes in models.py file. Reading from it the regular way of Model.objects.using('remote_db_name').get(pk=0) doesn't work because it throws a NameError.
I was wondering what is the correct way to handle both a local and remote database in Django, especially when the remote database only gives you SELECT and INSERT privileges. All the tutorials I've found online are about multiple databases defined in the same Django site, so the models.py file has all the data needed.
Thanks for any help in advance!
You have two options:
Use Django's legacy database support to autogenerate models for your existing database.
Skip the Django ORM, and use raw SQL to execute SQL statements against the database.
I had many hard-time moments with Django's legacy support - Django was not designed strictly to support legacy databases. Of course there are some tools/methods (like Ned told above) but I'd rather recommend SQLAlchemy as an alternative for you. It's very fast and it was designed to support any kind of databases no matter if they were created via sqlalchemy nor they were legacy dbs.
Of course if you need all other Django's elements, go for the Ned's solution, but remember that you have to create django core tables in this legacy db, so you'll need CREATE privilege.