Iam a beginner to django. I did run syncdb after mentioning the database file in manage.py. Is it possible to view the contents (tables) of the database in mysql or phpmyadmin?
Run dbshell:
python manage.py dbshell
This will put you in a shell as if running mysql with the correct connection params.
If you want to use phpmyadmin with it, that's a matter of correct phpmyadmin configuration, which depends only on your database, it has nothing to do with Django. So check your phpmyadmin settings and configure your database the same way you did in settings.py of the Django project.
phpMyAdmin does not support SQLite databases.
Related
I have a django rest app. It works fine with sqlite. Then I switched to using mysql. After I migrated the project. I imported a sql file to MySQL database. but got an error:
Table 'myusername$databasename.table_name1' doesn't exist
Table 'myusername$databasename.table_name2' doesn't exist
...
I don't understand. This sql file was exported from the same django project.
Please help me.
It seems you will need to create those tables first. That would correspond to the django command
./manage.py migrate
I am using django for my backend and mysql for database on nginx webserver on digitalocean. I want to use phpmyadmin to manipulate my database. Is there a way to do it?
Thank you.
Install phpmyadmin and manipulate the database however you want. You can setup Django to use the existing database from there.
I have an inscription.sql on a WAMP localhost:80 server, and I have also Django running on visual studio via a localhost:xxxx server.
I want to connect Django to the mysql database located on the wamp server (I have successfully installed MysqlClient).
Is there anyway to do this?
See the official guide to using an already existant database with Django.
To sum up, what you need to do is:
Make sure Django can connect to your database by setting the right DATABASE setting. From your comment, this seems to be the case.
Generate models (Python code) that match the tables in your database using the python manage.py inspectdb command. You must paste the generated code in the models.py file of an installed app and review them to make sure they fit your needs.
Create the tables required by Django with the python manage.py migrate command.
From the docs
Jus set the DATABASES variable in settings, then run python manage.py inspectdb > models.py put the generated models.py in the app's folder and finally run python manage.py migrate
I've Kallithea running on my own server with sqlite database. I would like to move all this data to MySQL database instead. On default Kallithea uses sqlite if not any other database is specified. From Kallithea documentation pdf https://media.readthedocs.org/pdf/kallithea/latest/kallithea.pdf they recommend to use https://github.com/shazow/sqlalchemygrate to migrate data from database to another.
I'm installed sqlalchemygrate using Python pip but when I try to migrate there is parts what I don't understand at all. Help menu doesn't not clearly specify how to use migrate command. At least I don't understand it at all. For example when I try to type
grate migrate "sqlite:./kallithea.db" "mysql://kallithea#localhost/kallithea"
I get error saying
ImportError: No module named sqlite
In help menu it says to use
migrate METADATA ENGINE_FROM ENGINE_TO
Migrate schema or data from one engine to another.
And example how to use it
grate migrate model.meta:metadata \
"mysql://foo:bar#localhost/baz" "sqlite:///:memory:" \
What I don't really understand is what is that metadata it needs? And how to specify sqlite .db file for this. And how to migrate data to new kallithea database in mysql with user kallithea which has all privileges to that database.
Not sure about Kallithea but RhodeCode users had a great success using TAPS (https://github.com/ricardochimal/taps) project to migrate they databases to different format.
ImportError: No module named sqlite
You probably need to install sqlite, and pip install sqlite or similar.
Regarding what metadata it needs, it's referring to metadata in the context of SQLAlchemy: http://docs.sqlalchemy.org/en/latest/core/metadata.html
I just joined a project where they have been using SQLite. I am more comfortable using MySQL with PHPMyAdmin. If I install phpMyAdmin and work with that will it do any damage?
It is a php project. They have alot of code (sloppy code thats so hard to figure out) for accessing a SQLite db. I dont want to effect that but I want to add some new tables to a new db using mysql and phpmyadmin which i am yet to set up because I'm afraid it will break the code written for the SQLite db
.
Are you talking merely about installing PHPMyAdmin to manage a SQLite database? That won't work, since both use completely different API's to be accessible through PHP.
Or do you wish to swap the SQLite database with MySQL and then use PHPMyAdmin to manage the database? That'll work, as long as the project supports both SQLite and MySQL.
Is it a PHP project? Probably not - mysql_-prefixed methods only work with MySQL as far as I know, and SQLite and MySQL don't listen on the same port by default, do they?
You need to work with what is deployed. If the project is using Sqlite, then use that. Databases are not all equal. If you use something different, your code might not even run on the production databases.
first of all, if you don't want affect, create a branch on github then from work this branch ..
you can also dump all table of this sqlite database to a sql file, then import this file to your phpAdmin, will create the table, since this both manager uses sql language ... just remove some ligne of code that are not compatible with mysql on sql file that you dump data from sqlite dabtase .....
here is the code for dump a sqlite database ....
first select the database on terminal on your project director
sqlite3
./open DATABASENAME
.output YOURSQLFILENAME.sql
.dump
.quit
at this stage you already have your database in a sql file
then use php admin to import this file
if it show some error, just try to remove somecode that aren't compatible with mysql on sqlfile.