Re: creating a new database with mysqldb
John Salerno [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. The web hotel I use create *one* database together with the account. I.O.W: I cannot create any databases; I can create/delete as many tables as I like within the database (up to the disk space that I have). This is pretty normal, I think. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Frithiof Andreas Jensen wrote: John Salerno [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. The web hotel I use create *one* database together with the account. I.O.W: I cannot create any databases; I can create/delete as many tables as I like within the database (up to the disk space that I have). This is pretty normal, I think. No, I can create 25 databases. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
BartlebyScrivener wrote: I was hoping you'd find this earlier when I suggested that you type: creating a new database with MySQL into google. It's the number one hit: http://coronet.iicm.edu/mysql/create.html If you send the commands listed there via the commandline or through MySQLdb you should be in business. I saw this one, but it seems to use a lot of the command line, and I didn't know how all that translates into a Python script. My goal was to do it all using just mysqldb, but maybe it's just easier (or more normal) to create a database in another way, and *then* use mysqldb to manipulate it. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Dennis Lee Bieber wrote: As a client on a shared host, I suspect the provider created a user account and A (one) database for that account. The privilege tables for that user account would have been set so that only that database is available. The account would have full privileges within that database, and no privileges to access any other database (including the mysql master tables). Depending the strictness of the provider, the account may or may not allow for connections from outside hosts, or only from localhost (ie, CGI applications that are running on the provider's machine, and not via mysql -u user -h somewhere.out.there -p or programmatic equivalents) I know for sure I can't connect from anywhere else, only the server itself. But I *think* I have full privileges to do what I want with the database, but I need to do some further checking, I suppose. It says I have 'amdmin privilegs' but that might not be the same as what I need to create databases outside of the control panel. -- http://mail.python.org/mailman/listinfo/python-list
creating a new database with mysqldb
Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. So is there a way to connect to your mysql server (without a specified database) in order to create a new database (i.e., the CREATE DATABASE query)? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Type: create a new database with mysql into google and see what happens rd -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
BartlebyScrivener wrote: Type: create a new database with mysql into google and see what happens rd Well, the thing about it is that all the guides I find online seem to begin with using a command prompt or a unix shell, neither of which will work in my case. I'm trying to find a way to access my database server using just a python script. Perhaps that isn't even possible for me to do without shell access. I might just have to use the msqladministrator in my server control panel, instead of using python. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Am Mittwoch 17 Mai 2006 21:23 schrieb John Salerno: Well, the thing about it is that all the guides I find online seem to begin with using a command prompt or a unix shell, neither of which will work in my case. I'm trying to find a way to access my database server using just a python script. Perhaps that isn't even possible for me to do without shell access. I might just have to use the msqladministrator in my server control panel, instead of using python. Creating a database is just another SQL command in MySQL (which you can easily send to the MySQL server you're using with Python and MySQLdb): CREATE DATABASE dbname Of course, you need to log on with a user who is allowed to create databases. See the MySQL documentation for more info on the available CREATE commands. --- Heiko. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
John Salerno wrote: Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. So is there a way to connect to your mysql server (without a specified database) in order to create a new database (i.e., the CREATE DATABASE query)? Thanks. I'm no expert but: can't you spawn mysql with a script/scheme ? Philippe -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
I would learn basic, commandline SQL first and get comfortable creating tables, querying your dbs etc. THEN, add Python. Otherwise you spin your wheels not knowing whether it's your use of the Python modules or your bad SQL commands that are fouling things up. http://sqlcourse.com/intro.html or I recommend Chris Fehily's SQL 2nd Ed. Great book, and cheap. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Heiko Wundram wrote: Of course, you need to log on with a user who is allowed to create databases. yeah, this is where I'm stuck. The only logging on i know how to do is with the connect method, but that requires a database to exist already -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
BartlebyScrivener wrote: I would learn basic, commandline SQL first and get comfortable creating tables, querying your dbs etc. THEN, add Python. Otherwise you spin your wheels not knowing whether it's your use of the Python modules or your bad SQL commands that are fouling things up. http://sqlcourse.com/intro.html or I recommend Chris Fehily's SQL 2nd Ed. Great book, and cheap. I did that tutorial yesterday. It was great and I learned a lot about the basics of working with tables. After learning the queries, then I moved on to using them with Python. I plan to get the pocket reference later today, so that might help as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
On 5/17/06, Philippe Martin [EMAIL PROTECTED] wrote: John Salerno wrote: Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. So is there a way to connect to your mysql server (without a specified database) in order to create a new database (i.e., the CREATE DATABASE query)? Thanks.I'm no expert but: can't you spawn mysql with a script/scheme ?Philippe MySQLdb.connect does not require a database name. ie.: import MySqlDB db = MySQLdb.connect(host='localhost', user='root', passwd='') csr = db.cursor () csr.execute('''show databases''')6L for d in csr.fetchall(): print d('cc',)('cc_41',)('mysql',)('purchaseorder',)('test',)('xsldb',) csr.execute('''create database newdb''')1L csr.execute('''show databases''')7L for d in csr.fetchall(): print d('cc',)('cc_41',)('mysql',)('newdb',)('purchaseorder',) ('test',)('xsldb',) Later,Lou-- Artificial Intelligence is no match for Natural Stupidity -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
John Salerno wrote: Since the connect method of mysqldb requires a database name, it seems like you can't use it without having a database already created. So is there a way to connect to your mysql server (without a specified database) in order to create a new database (i.e., the CREATE DATABASE query)? Thanks. In every MySQL library I have ever seen, the database parameter is optional. You may either omit it or pass an empty string. It is just a shortcut so the application does not need to send a USE command to select the active database. import MySQLdb db = MySQLdb.connect(host,username,password) c = db.cursor() To get the currently selected database: c.execute(SELECT DATABASE()) 1L c.fetchall() ((None,),) ^^^ None (NULL) indicates no currently selected database. To set the default database: c.execute(USE mysql) 0L Getting the database again: c.execute(SELECT DATABASE()) 1L c.fetchall() (('mysql',),) ^^^ A string indicates that a database is currently selected. Hope this helps. -- Jesse Hager email = [EMAIL PROTECTED].decode(rot13) -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
Jesse Hager wrote: In every MySQL library I have ever seen, the database parameter is optional. You may either omit it or pass an empty string. It is just a shortcut so the application does not need to send a USE command to select the active database. I tried it without the db parameter, then sent a CREATE TABLE query, but I got this: OperationalError: (1046, 'No Database Selected') -- http://mail.python.org/mailman/listinfo/python-list
Re: creating a new database with mysqldb
I was hoping you'd find this earlier when I suggested that you type: creating a new database with MySQL into google. It's the number one hit: http://coronet.iicm.edu/mysql/create.html If you send the commands listed there via the commandline or through MySQLdb you should be in business. -- http://mail.python.org/mailman/listinfo/python-list