def makeDB(self): create_string = "CREATE DATABASE '%s' user '%s' password '%s'" % ( self.dbname, self.login, self.passwd) if os.path.exists(self.dbname): os.remove(self.dbname) geocoding_db = kinterbasdb.create_database(create_string) self.makeConnection()
def startDB(self): import kinterbasdb self.DB_NAME = os.path.join(self.DB_DIR, DBTestConnector.DB_NAME) os.chmod(self.DB_DIR, stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO) sql = 'create database "%s" user "%s" password "%s"' sql %= (self.DB_NAME, self.DB_USER, self.DB_PASS); conn = kinterbasdb.create_database(sql) conn.close()
def startDB(self): import kinterbasdb self.DB_NAME = os.path.join(self.DB_DIR, DBTestConnector.DB_NAME) os.chmod(self.DB_DIR, stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO) sql = 'create database "%s" user "%s" password "%s"' sql %= (self.DB_NAME, self.DB_USER, self.DB_PASS) conn = kinterbasdb.create_database(sql) conn.close()
def startDB(self): import kinterbasdb if not os.path.exists(self.DB_DIR): os.mkdir(self.DB_DIR) os.chmod(self.DB_DIR, stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO) sql = 'create database "%s" user "%s" password "%s"' sql %= (self.DB_NAME, self.DB_USER, self.DB_PASS); conn = kinterbasdb.create_database(sql) conn.close() os.chmod(self.DB_NAME, stat.S_IRWXU + stat.S_IRWXG + stat.S_IRWXO)
def _create_database(self, test_database_name): params = self._get_connection_params(database=test_database_name) connection = Database.create_database(""" CREATE DATABASE '%(database)s' USER '%(user)s' PASSWORD '%(password)s' DEFAULT CHARACTER SET %(charset)s;""" % params) connection.execute_immediate("CREATE EXCEPTION teste '';") connection.commit()
def SetUp(self, context, result): # Generate a database. self.__FirebirdServices = FirebirdService(context) self.__database_path = "".join((context["server_location"], \ context["database_location"],self.database_name)) context["user_name"] = self.user_name context["user_password"] = self.user_password if self.backup_file: try: self.__FirebirdServices.RestoreDatabase( context["database_location"] + self.database_name, self.backup_file, [ "-P", self.page_size, "-user", self.user_name, "-password", self.user_password ], result) except: result.NoteException() else: # Setup succeeded. Store the path to the database where # tests can get at it. context[self.database_path_property] = self.__database_path else: self.__sql_statement = "CREATE DATABASE '"+self.__database_path + \ "' USER '"+self.user_name+"' PASSWORD '"+self.user_password + \ "' PAGE_SIZE "+self.page_size+" DEFAULT CHARACTER SET " + \ self.character_set # print self.__sql_statement try: # Create the database. self.__con = kinterbasdb.create_database( self.__sql_statement, int(self.sql_dialect)) self.__con.close() # print "Database created !" if self.init_script: try: self.__FirebirdServices.RunScript( context["database_location"] + self.database_name, self.init_script, [ "-user", self.user_name, "-password", self.user_password ], result) except: result.NoteException() except Exception, error: # Setup failed. cause = "Database creation failed. %s" % str(error) result.Fail(cause) else:
def __init__(self, ui, filename=None, dsn=None, host=None, user="******", pwd="masterkey"): SqlConnection.__init__(self, ui) self.dbapi = kinterbasdb self._user = user self._pwd = pwd if dsn is not None: assert host is None assert filename is None host, filename = dsn.split(':', 1) self._host = host if filename is None: self._filename = r"c:\temp\tmp.fdb" self._host = "localhost" if os.path.exists(self._filename): os.remove(self._filename) else: self._filename = filename if os.path.exists(filename): self._mtime = os.stat(filename).st_mtime self._status = self.CST_OPENED self._dbconn = kinterbasdb.connect(host=self._host, database=filename, user=self._user, password=self._pwd) self.setup_connection() return self._mtime = 0.0 self._dbconn = kinterbasdb.create_database( "create database '%s:%s' user '%s' password '%s'" % (self._host, self._filename, self._user, self._pwd)) self.setup_connection()
def __init__(self,ui, filename=None, dsn=None, host=None, user="******",pwd="masterkey"): SqlConnection.__init__(self,ui) self.dbapi = kinterbasdb self._user=user self._pwd=pwd if dsn is not None: assert host is None assert filename is None host,filename=dsn.split(':',1) self._host=host if filename is None: self._filename=r"c:\temp\tmp.fdb" self._host="localhost" if os.path.exists(self._filename): os.remove(self._filename) else: self._filename = filename if os.path.exists(filename): self._mtime = os.stat(filename).st_mtime self._status = self.CST_OPENED self._dbconn = kinterbasdb.connect( host=self._host, database=filename, user=self._user, password=self._pwd) self.setup_connection() return self._mtime = 0.0 self._dbconn = kinterbasdb.create_database( "create database '%s:%s' user '%s' password '%s'" % ( self._host,self._filename, self._user,self._pwd)) self.setup_connection()
def _create_database(self, test_database_name): params = self._get_connection_params(database=test_database_name) connection = Database.create_database( "CREATE DATABASE '%(database)s' user '%(user)s' password '%(password)s'" % params )