- How to I access MySQL from a Python CGI script?
- MySQL access w/o shell
- how do I reset an auto_increment column?
- How do I use mysql from the shell?
- How do upload an existing mysql database?
- how can I back up my database if I don't have a shell account?
How to I access MySQL from a Python CGI script?
The Python MySQLdb module is installed. Sample code:
1 2 3 4 5 6 | import MySQLdb
db = MySQLdb.connect(host="db.sabren.com", user="username", passwd="password", db="your_db")
cursor = db.cursor()
cursor.execute("select * from table where id = 3")
row = cursor.fetchone()
print row |
About the only other thing I needed to know was that the the returned items will be in a tuple if there is more than one, not a list. Good to know if you want to do some post processing of the results. - DominicFitzpatrick
More documentation: http://www.devshed.com/Server_Side/Python/PythonMySQL/
Note: This link appears to be dead or otherwise missing - CharlesLaShure
MySQL access w/o shell
The easiest way to see your database is to log into the web based manager (PHPMyAdmin):
Remember to use your DATABASE username and password, not your normal ftp/mail pair.
The other option to ask for remote access, in which case you could connect from the command line MySQL client from home or a GUI tool like Mascon:
how do I reset an auto_increment column?
ALTER TABLE tbl_name AUTO_INCREMENT = 1;
How do I use mysql from the shell?
mysql -h db.sabren.com -u user -ppassword dbname (dont forget the -h db.sabren.com)
How do upload an existing mysql database?
Use mysqldump.
% mysqldump -h old.db.server.com -u old_user -p old_database > data.sql [enter password]
To reimport into a blank database:
% mysql -h db.sabren.com -u user -p database < data.sql [enter password]
how can I back up my database if I don't have a shell account?
Go to http://db.sabren.com and
-
Log in with your DATABASE username and password
-
click on the database name (noteitposts_db) in the upper left frame
-
click export tab in the right frame
-
click select all
-
click save as file
-
click gzipped
-
click "go"
